Skip Menu |
Report information
Id: 131343
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: enheh [at] protonmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Date: Mon, 22 May 2017 12:59:59 -0400
To: "rakudobug [...] perl.org" <rakudobug [...] perl.org>
From: Enheh <enheh [...] protonmail.com>
Subject: [BUG] Constraining an attribute to a defined version of a type passed to a parameterized role fails.
Download (untitled) / with headers
text/plain 747b
# Rakudo version 2017.04.3 built on MoarVM version 2017.04-53-g66c6dda implementing Perl 6.c.

# Not constraining to a defined type works:
role R[::T] {
    has T $.x = T.new(0);
    method new() {return self.bless(:x(42e0));}
};
class C does R[Num] {};
C.new();

# Constraining to a defined type works if the type constraint is not parameterized.
role R {
    has Num:D $.x = Num.new(0);
    method new() {return self.bless(:x(42e0));}
};
class C does R {};
C.new();

# Both parameterizing and constraining to a defined type fails.
role R[::T] {
    has T:D $.x = T.new(0);
    method new() {return self.bless(:x(42e0));}
};
class C does R[Num] {};
C.new();               
# OUTPUT: X::TypeCheck::Assignment exception produced no message


# The failure seems to occur during the bless.



This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org