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

Owner: Nobody
Requestors: smls75 [at] gmail.com
tomentiruran [at] gmail.com
Cc:
AdminCc:

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 [...] gmail.com>
Date: Tue, 22 Aug 2017 17:28:38 +0200
To: Rakudo Bugtracker <rakudobug [...] perl.org>
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; # Perl6::Metamodel::GenericHOW.new
Date: Sun, 10 Sep 2017 19:27:13 +0800
From: Andrew Buchanan <tomentiruran [...] gmail.com>
Subject: Role type parameter doesn't initialise properly
To: rakudobug [...] perl.org
Download (untitled) / with headers
text/plain 696b
> 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. 

--
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.
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
...



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