This is yet another compile time closure serialisation bug. I made a list of all of them I could find:
https://rt.perl.org/Public/Bug/Display.html?id=125634 <https://rt.perl.org/Public/Bug/Display.html?id=126818> https://rt.perl.org/Public/Bug/Display.html?id=126818 https://rt.perl.org/Public/Bug/Display.html?id=127034 https://rt.perl.org/Public/Bug/Display.html?id=127112 <https://rt.perl.org/Public/Bug/Display.html?id=127858> https://rt.perl.org/Public/Bug/Display.html?id=127858 <https://rt.perl.org/Public/Bug/Display.html?id=127860> https://rt.perl.org/Public/Bug/Display.html?id=127860 https://rt.perl.org/Public/Bug/Display.html?id=127959 and added this one to the list :) On Sun, Apr 24, 2016 at 5:02 AM Pierre VIGIER <[email protected]> wrote: > # New Ticket Created by Pierre VIGIER > # Please include the string: [perl #127959] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=127959 > > > > Hi > > Basically, i have a trait that add a method to a class if applied to an > attribute > it's working well > however, if i try to 'use' a class that uses that trait, i have a strange > error: > Missing serialize REPR function for REPR SCRef > > To show case the issue, here is a dummy module, that export a trait > "mytrait". > That trait if applied to any attribute of a class, will add a new method > nn to the class that returns 'nn'. > (the original module is AttrX::Lazy, just wanted to trimdown the code base) > > file mytraitmodule.pm6 contains that trait > > you can see that tiny trait in action with the following: > > PERL6LIB=$PWD perl6 -e 'use mytraitmodule; class Foo { has $!att is > mytrait; }; say Foo.new().nn()' [22:18:23] > > nn > > The trait is working fine. > > Now, if i create a class in a separate file, that does the same thing, and > load the class, for the class see file myclass.pm6 > and i just try to use that new class, with a simple code like: > > PERL6LIB=$PWD perl6 -e 'use myclass;' > [22:18:12] > ===SORRY!=== > Missing serialize REPR function for REPR SCRef > > You see the issue, really strange, the trait is working by itself, but > it's impossible to load a class that uses that trait > > RabidGravy on IRC told me to add a no precompilation statement on top of > the file having the role to temporary solve the issue, and i can confirm it > is working. > > Content of the files: > myclass.pm6: > -------------------- > unit class myclass; > use mytraitmodule; > > has $!bar is mytrait; > -------------------- > > > mytraitmodule.pm6: > -------------------- > unit module mytraitmodule; > my role rrHOW { > method compose(Mu \type) { > type.^add_method('nn', method (Mu:D:) { return 'nn' ; } ); > callsame; > } > } > > multi trait_mod:<is>(Attribute:D $attr, :$mytrait! ) is export { > $attr.package.HOW does rrHOW; > } > -------------------- > > > Pierre >
