# 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").
#!/usr/bin/env perl6

use v6;
use testimport;

test("a");
#!/usr/bin/env perl6

unit module testimport;

multi sub trait_mod:<is>(Routine:D $r, :$wrapped!) {
    $r.wrap: -> |args {
        put "test, successfully wrapped";
        callsame
    }
}

sub test(Str $a) is wrapped is export {
    $a.say
}

Reply via email to