Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #3558

Open
p6rt opened this issue Oct 16, 2014 · 3 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 16, 2014

Migrated from rt.perl.org#122992 (status was 'open')

Searchable as RT122992$

@p6rt
Copy link
Author

p6rt commented Oct 16, 2014

From @masak

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]'"

@p6rt
Copy link
Author

p6rt commented Dec 3, 2017

From @AlexDaniel

Seems to be reproducible (2017.11,HEAD(e5b660e))

On 2014-10-16 13​:43​:34, masak wrote​:

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]'"

@p6rt
Copy link
Author

p6rt commented Dec 3, 2017

The RT System itself - Status changed from 'new' to 'open'

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant