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

Roles composed through two different paths and also containing an attribute with a default triggers a bogus error in Rakduo #2485

Closed
p6rt opened this issue Sep 27, 2011 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 27, 2011

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

Searchable as RT100124$

@p6rt
Copy link
Author

p6rt commented Sep 27, 2011

From @masak

<masak> ok, here we go.
<masak> nom​: my $x; role A { has $!foo }; role B does A {}; role C
does A {}; class D does B does C {}; say "alive"
<p6eval> nom 41eceb​: OUTPUT«alive␤»
<masak> nom​: my $x; role A { has $!foo = $x }; role B does A {}; role
C does A {}; class D does B does C {}
<p6eval> nom 41eceb​: OUTPUT«===SORRY!===␤Attribute '$!foo' conflicts
in role composition␤»
<masak> b​: my $x; role A { has $!foo = $x }; role B does A {}; role C
does A {}; class D does B does C {}; say "alive"
<p6eval> b 1b7dd1​: OUTPUT«alive␤»
* masak submits rakudobug
<masak> note, that external reference to $x is *necessary* to trigger
the role composition error.
<jnthn> Ah, that kinda follows.
<masak> it does?
<masak> I'm glad it's obvious to one of us :P
<jnthn> masak​: Attributes that have defaults always get their
meta-objects generically instantiated.
<jnthn> masak​: Because the default may refer to role arguments.
<masak> oh!
<jnthn> masak​: I suspect we're doing an identity check in the role composer.
<masak> nom​: my $x; role A { has $!foo = 42 }; role B does A {}; role
C does A {}; class D does B does C {}; say "alive"
<p6eval> nom 41eceb​: OUTPUT«===SORRY!===␤Attribute '$!foo' conflicts
in role composition␤»
<jnthn> masak​: And instead it wants to check name + declaring package.
<masak> ok, so this is a bug? phew!
<jnthn> Yeah, it should be fixed.
* masak beams
<jnthn> Just thought an explanation of why the default value matters
might be interesting. ;)
<masak> was a long time I found a bug as juicy as this :)
<jnthn> It's subtle, yes.

So​: define role with attribute with a default. Compose it twice
(legitimately) into a class. Boom.

@p6rt
Copy link
Author

p6rt commented Nov 21, 2012

From @FROGGS

By reading the discussion it looks like the expected behaviour is there now​:

<FROGGS> r​: my $x; role A { has $!foo }; role B does A {}; role C does A
{}; class D does B does C {}; say "alive"
<p6eval> rakudo bf472b​: OUTPUT«===SORRY!===␤Attribute '$!foo' conflicts
in role composition␤»
<FROGGS> r​: my $x; role A { has $!foo = $x }; role B does A {}; role C
does A {}; class D does B does C {}
<p6eval> rakudo bf472b​: OUTPUT«===SORRY!===␤Attribute '$!foo' conflicts
in role composition␤»

@p6rt
Copy link
Author

p6rt commented Nov 21, 2012

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

@p6rt p6rt closed this as completed Apr 7, 2016
@p6rt
Copy link
Author

p6rt commented Apr 7, 2016

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

@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