Skip Menu |
Report information
Id: 122992
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: masak <cmasak [at] gmail.com>
Cc:
AdminCc:

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



Date: Thu, 16 Oct 2014 22:43:22 +0200
To: rakudobug [...] perl.org
From: Carl Mäsak <cmasak [...] gmail.com>
Subject: [BUG] Declaring a 'my' array or hash typed with a type parameter ends up blowing up with a fixable error message about instantiating generics in Rakudo
Download (untitled) / with headers
text/plain 2.3k
camelia was having some indigestion in the below backlog, which is why I'm reporting some local evals (from "This is perl6 version 2014.09-202-g8b3e8c2 built on MoarVM version 2014.09-54-g03ac9a7"). <masak> m: class A { my ::?CLASS @.foo }; A.foo.push(2) <camelia> rakudo-moar 86dc3c: OUTPUT«(timeout)» <masak> locally, "Type check failed in .push; expected 'A' but got 'Int'" <masak> (wow) <masak> lizmat++ jnthn++, no doubt <timotimo> masak: are they to blame for this? :) <masak> timotimo: it's amazing! it recognizes `A` as the current class, *and* it typechecks against it on .push <masak> timotimo: woot! <timotimo> that *is* neat. <jnthn> masak: Note it's more useful use is in roles, where ::?CLASS is generic. <masak> jnthn: I'm just about to factor my current code into a role :> <masak> aww. <masak> ===SORRY!=== <masak> No such method 'instantiate_generic' for invocant of type 'Array[::?CLASS]' <jnthn> Awww :( <masak> m: role R { my ::?CLASS @.x }; class C does R {}; say "alive" <masak> locally: "No such method 'instantiate_generic' for invocant of type 'Array[::?CLASS]'" <camelia> rakudo-moar 86dc3c: OUTPUT«(timeout)» <masak> jnthn: any non-torment reason that shouldn't be possible? <masak> m: role R { my ::?CLASS $.x }; class C does R {}; say "alive" <masak> locally: "alive" <camelia> rakudo-moar 86dc3c: OUTPUT«(timeout)» <masak> if I remove the ::?CLASS type constraint, using a role still works. <masak> m: role R { has ::?CLASS @.x }; class C does R {}; say "alive" <masak> locally: "alive" <camelia> rakudo-moar 86dc3c: OUTPUT«(timeout)» <masak> so it's only in the very specific case of `my` + `::?CLASS` + `@` that it blows up... <masak> oh, and `role` <jnthn> masak: It's the "my" that does it <jnthn> masak: I think it's fixable <masak> nice. * masak submits rakuodbug <jnthn> Well, I'd not say it'll be nice to fix, but... :P <jnthn> m: sub foo(::T $x) { my T @a; }; foo(42) <camelia> rakudo-moar 86dc3c: OUTPUT«No such method 'instantiate_generic' for invocant of type 'Array[T]' [...] <jnthn> Hah, gulf. :) <masak> :) <masak> but `my`, type parameter, and `@` sigil are still essential, yes? <jnthn> Yes, but it can be a type parameter of a role or the sub <masak> m: sub foo(::T $x) { my T %h; }; foo(42) <camelia> rakudo-moar 86dc3c: OUTPUT«(timeout)» <masak> locally, "No such method 'instantiate_generic' for invocant of type 'Hash[T]'"
Seems to be reproducible (2017.11,HEAD(e5b660e))

On 2014-10-16 13:43:34, masak wrote:
Show quoted text
> camelia was having some indigestion in the below backlog, which is why
> I'm reporting some local evals (from "This is perl6 version
> 2014.09-202-g8b3e8c2 built on MoarVM version 2014.09-54-g03ac9a7").
>
> <masak> m: class A { my ::?CLASS @.foo }; A.foo.push(2)
> <camelia> rakudo-moar 86dc3c: OUTPUT«(timeout)»
> <masak> locally, "Type check failed in .push; expected 'A' but got
> 'Int'"
> <masak> (wow)
> <masak> lizmat++ jnthn++, no doubt
> <timotimo> masak: are they to blame for this? :)
> <masak> timotimo: it's amazing! it recognizes `A` as the current
> class, *and* it typechecks against it on .push
> <masak> timotimo: woot!
> <timotimo> that *is* neat.
> <jnthn> masak: Note it's more useful use is in roles, where ::?CLASS
> is generic.
> <masak> jnthn: I'm just about to factor my current code into a role :>
> <masak> aww.
> <masak> ===SORRY!===
> <masak> No such method 'instantiate_generic' for invocant of type
> 'Array[::?CLASS]'
> <jnthn> Awww :(
> <masak> m: role R { my ::?CLASS @.x }; class C does R {}; say "alive"
> <masak> locally: "No such method 'instantiate_generic' for invocant of
> type 'Array[::?CLASS]'"
> <camelia> rakudo-moar 86dc3c: OUTPUT«(timeout)»
> <masak> jnthn: any non-torment reason that shouldn't be possible?
> <masak> m: role R { my ::?CLASS $.x }; class C does R {}; say "alive"
> <masak> locally: "alive"
> <camelia> rakudo-moar 86dc3c: OUTPUT«(timeout)»
> <masak> if I remove the ::?CLASS type constraint, using a role still
> works.
> <masak> m: role R { has ::?CLASS @.x }; class C does R {}; say "alive"
> <masak> locally: "alive"
> <camelia> rakudo-moar 86dc3c: OUTPUT«(timeout)»
> <masak> so it's only in the very specific case of `my` + `::?CLASS` +
> `@` that it blows up...
> <masak> oh, and `role`
> <jnthn> masak: It's the "my" that does it
> <jnthn> masak: I think it's fixable
> <masak> nice.
> * masak submits rakuodbug
> <jnthn> Well, I'd not say it'll be nice to fix, but... :P
> <jnthn> m: sub foo(::T $x) { my T @a; }; foo(42)
> <camelia> rakudo-moar 86dc3c: OUTPUT«No such method
> 'instantiate_generic' for invocant of type 'Array[T]' [...]
> <jnthn> Hah, gulf. :)
> <masak> :)
> <masak> but `my`, type parameter, and `@` sigil are still essential,
> yes?
> <jnthn> Yes, but it can be a type parameter of a role or the sub
> <masak> m: sub foo(::T $x) { my T %h; }; foo(42)
> <camelia> rakudo-moar 86dc3c: OUTPUT«(timeout)»
> <masak> locally, "No such method 'instantiate_generic' for invocant of
> type 'Hash[T]'"




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