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

Something is wrong with instantiation of generic roles and typed attributes in Rakudo #2641

Closed
p6rt opened this issue Feb 5, 2012 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Feb 5, 2012

Migrated from rt.perl.org#109880 (status was 'resolved')

Searchable as RT109880$

@p6rt
Copy link
Author

p6rt commented Feb 5, 2012

From @masak

<masak> nom​: role Foo[​::T] { has T @​.a = [T] }; class Bar {}; say
Foo[Bar].new.a[0]
<p6eval> nom a17736​: OUTPUT«Cannot type check against type variable T [...]
<masak> jnthn​: what's up with this?
<jnthn> hm
<jnthn> nom​: my $r = role Foo[​::T] { has T @​.a }; $r.HOW.attributes($r).perl.say
<p6eval> nom 5a2c7d​: OUTPUT«Method 'mro' not found for invocant of
class 'Perl6​::Metamodel​::ParametricRoleHOW' [...]
<jnthn> ...interesting.
<jnthn> nom​: my $r = role Foo[​::T] { has T @​.a };
$r.HOW.attributes($r, :local).[0].type.HOW.archetypes.generic.say
<p6eval> nom 5a2c7d​: OUTPUT«1␤»
<jnthn> Hm, that much is right then.
<jnthn> masak​: Not sure without going for a deeper dig...some kind of
generic instantiation failure.
* masak submits rakudobug

@p6rt
Copy link
Author

p6rt commented Jan 25, 2015

From @usev6

As a status update​: This behaves differently now.

$ perl6-m -e 'role Foo[​::T] { has T @​.a = [T] }; class Bar {}; say Foo[Bar].new.a[0]'
Type check failed in assignment to '@​!a'; expected 'Bar' but got 'Array'
  in method REIFY at src/gen/m-CORE.setting​:9935
  in method reify at src/gen/m-CORE.setting​:8543
  in method gimme at src/gen/m-CORE.setting​:9024
  in method sink at src/gen/m-CORE.setting​:9513
  in method BUILDALL at src/gen/m-CORE.setting​:1043
  in method bless at src/gen/m-CORE.setting​:961
  in method new at src/gen/m-CORE.setting​:947
  in any at src/gen/m-Metamodel.nqp​:1510
  in block <unit> at -e​:1

$ perl6-m -e 'my $r = role Foo[​::T] { has T @​.a }; $r.HOW.attributes($r).perl.say'
(Attribute.new(),)

$ perl6-m -e 'my $r = role Foo[​::T] { has T @​.a }; $r.HOW.attributes($r, :local).[0].type.HOW.archetypes.generic.say'
1

1 similar comment
@p6rt
Copy link
Author

p6rt commented Jan 25, 2015

From @usev6

As a status update​: This behaves differently now.

$ perl6-m -e 'role Foo[​::T] { has T @​.a = [T] }; class Bar {}; say Foo[Bar].new.a[0]'
Type check failed in assignment to '@​!a'; expected 'Bar' but got 'Array'
  in method REIFY at src/gen/m-CORE.setting​:9935
  in method reify at src/gen/m-CORE.setting​:8543
  in method gimme at src/gen/m-CORE.setting​:9024
  in method sink at src/gen/m-CORE.setting​:9513
  in method BUILDALL at src/gen/m-CORE.setting​:1043
  in method bless at src/gen/m-CORE.setting​:961
  in method new at src/gen/m-CORE.setting​:947
  in any at src/gen/m-Metamodel.nqp​:1510
  in block <unit> at -e​:1

$ perl6-m -e 'my $r = role Foo[​::T] { has T @​.a }; $r.HOW.attributes($r).perl.say'
(Attribute.new(),)

$ perl6-m -e 'my $r = role Foo[​::T] { has T @​.a }; $r.HOW.attributes($r, :local).[0].type.HOW.archetypes.generic.say'
1

@p6rt
Copy link
Author

p6rt commented Jan 25, 2015

@usev6 - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented May 15, 2015

From @jdv

[jdv@​wieldy ~]$ perl6 -e 'role Foo[​::T] { has T @​.a = T }; class Bar {}; say Foo[Bar].new.a[0]'(Bar)
[jdv@​wieldy ~]$

looks like more valid code than

[jdv@​wieldy ~]$ perl6 -e 'role Foo[​::T] { has T @​.a = [T] }; class Bar {}; say Foo[Bar].new.a[0]'
Type check failed in assignment to '@​!a'; expected 'Bar' but got 'Array'
  in any at src/gen/m-Metamodel.nqp​:1640
  in block <unit> at -e​:1

[jdv@​wieldy ~]$

@p6rt
Copy link
Author

p6rt commented May 28, 2015

From @jdv

Added tests in S14-roles/parameterized-basic.t.

@p6rt
Copy link
Author

p6rt commented May 28, 2015

@jdv - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant