# New Ticket Created by  "Carl Mäsak" 
# Please include the string:  [perl #100124]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=100124 >


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

Reply via email to