Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

Cannot bind to role attribute from a class #5772

Open p6rt opened 7 years ago

p6rt commented 7 years ago

Migrated from rt.perl.org#130030 (status was 'new')

Searchable as RT130030$

p6rt commented 7 years ago

From @lizmat

\ m​: role A { has $!foo }; class B does A { method b() { $!foo := 42 } }; B.b # shouldn't this just work ? \ rakudo-moar 8b40d1​: OUTPUT«X​::TypeCheck​::Binding exception produced no message␤ in method b at \ line 1␤ in block \ at \ line 1␤␤» \ jnthn ^^^ \ m​: role A { has $!foo }; class B does A { method b() { $!foo := 42 } }; B.new.b \ rakudo-moar 8b40d1​: OUTPUT«X​::TypeCheck​::Binding exception produced no message␤ in method b at \ line 1␤ in block \ at \ line 1␤␤» \ m​: role A { has $!foo }; class B does A { method b() { $!foo = 42 } }; B.new.b \ rakudo-moar 8b40d1​: ( no output ) \ yeah, I missed the .new in my example, but the result is the same, no? \ binding just doesn't work \ right \ are assignments to native attributes already just nqp​::bindattr? \ er, not "native" \ but that kind of makes it awkward to put Scalar objects into attributes and assigning binds the new value to replace the scalar instead of assigning into the scalar? \ except if you use accessors, you potentially get an AttrRef that's scalar-like? perhaps? \ what I want to achieve is to bind an nqp​::list from a '$!reified' slot \ if I just assign, I get this​: \ $ 6l 'my @​a[10] = ^10; say @​a.iterator.pull-one' \ Segmentation fault​: 11 \ :-( \ ok, I guess I'll work around it :-( \ timotimo​: do you agree this is buggable ? \ huh, ouch \ lizmat​: all segfaults are buggable \ quite