This is another outer context lost with compile time closure bug. It's one of the most prolific bugs in rakudo :(.
I've added this ticket to the list: 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=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=127860 https://rt.perl.org/Public/Bug/Display.html?id=127959 https://rt.perl.org/Public/Bug/Display.html?id=107844 https://rt.perl.org/Public/Bug/Display.html?id=128636 https://rt.perl.org/Public/Bug/Display.html?id=129096 On Sat, 27 Aug 2016 at 10:04 AM, Eike Frost <perl6-bugs-follo...@perl.org> wrote: > # New Ticket Created by Eike Frost > # Please include the string: [perl #129096] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=129096 > > > > Tested on version 2016.07.1, 2016.08.1: > > When executing test2.pl, the error > > Cannot invoke this object (REPR: Null; VMNull) > in block at (...)testimport.pm (testimport) line 7 > in any enter at gen/moar/m-Metamodel.nqp line 4012 > in block <unit> at test2.pl line 6 > > is displayed. When using the same code within the same file (i.e. without > an import of the wrapped sub), everything works as expected (i.e. output is > > test, successfully wrapped > a > > I asked about this in #perl6. It is not 100% clear that what I am trying to > do is supported: > > 12:25 < nine> ejf: well you probably mean to export the wrapped sub but > that would mean that rakudo has to process the traits in the right way and > I'm not sure that's guaranteed. Could be that that's just a combination of > features > that's not really feasible to support. > 12:26 < nine> ejf: could also be just a plain straight forward bug in > rakudo :) I'm not familiar enough with that part to make a good guess and > am too tired to start debugging right now > > (for reference, this also does not work if the trait_mod is part of an > exported class or is itself marked with "is export"). >