You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
➜ 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; # Perl6::Metamodel::GenericHOW.new
role R[::T] { has T $.r is rw }
(R)
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.
--
perl6 -v
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.
perl6 -V
distro::auth=Apple Computer, Inc.
distro::desc=2017-09-09T09:21:56.148447+08:00
distro::is-win=False
distro::name=macosx
distro::path-sep=:
distro::release=16G29
distro::signature=
distro::version=10.12.6
...
Migrated from rt.perl.org#131947 (status was 'new')
Searchable as RT131947$
The text was updated successfully, but these errors were encountered: