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

Owner: Nobody
Requestors: smls75 [at]
tomentiruran [at]

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

Subject: [OO] Using a role parameter to constrain an uninitialized attribute, leaks a generic type object.
From: Sam S <smls75 [...]>
Date: Tue, 22 Aug 2017 17:28:38 +0200
To: Rakudo Bugtracker <rakudobug [...]>
Download (untitled) / with headers
text/plain 651b
This works: ‎‎ ➜ role R [::T] { has T $.a = T }; say R[Int].new.a; ‎‎ (Int) But remove the explicit initializer `= T` (which should be redundant, right?), and it blows up: ‎‎ ➜ role R [::T] { has T $.a }; say R[Int].new.a; ‎‎ No such method 'gist' for invocant of type 'T' ‎‎ in block <unit> at <unknown file> line 1 Looks like the automatic initializer for `$.a` leaves the type object of the generic type T in the attribute, instead of letting it become the concrete type Int. Some introspection: say R[Int].new.a.^name; # T say R[Int].new.a.HOW; #
Date: Sun, 10 Sep 2017 19:27:13 +0800
From: Andrew Buchanan <tomentiruran [...]>
Subject: Role type parameter doesn't initialise properly
To: rakudobug [...]
Download (untitled) / with headers
text/plain 696b
> role R[::T] { has T $.r is rw }
> R[Str].new.perl
No such method 'perl' for invocant of type 'T'
  in block <unit> at <unknown file> line 1

> R[Str].new.r = Nil
No such method 'WHERE' for invocant of type 'T'

> R[Str].new(:r("r")).perl
R[Str].new(r => "r")

However, it works if $.r is initalised to T, which is presumably what the object creation should be doing. 

Show quoted text
> perl6 -v
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.
Show quoted text
> perl6 -V
distro::auth=Apple Computer, Inc.

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

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