Method wrapper using multiple source files

I am trying to understand how wrapping works in perl6. I am using this code:

First file (test.pl6):

use v6;
use lib '.';

use TestClass;

my TestClass $t .= new;
$t.wrapped(1, 7);

Second file (TestClass.pm6):

multi sub trait_mod:<is>(Routine:D \r, :$dummy!)
{
    r.wrap(sub (|)
    {
        say 'Dummy';
        callsame;
    });
}

unit class TestClass;

method wrapped($a, $b) is dummy
{
    say "Wrapped ($a, $b)";
}

When running test.pl6, I get:

Cannot invoke this object (REPR: Null; VMNull)
  in sub  at TestClass.pm6 (TestClass) line 5
  in any enter at gen/moar/Metamodel.nqp line 3999
  in block <unit> at test.pl6 line 7

When all the above code is in one file, it works and prints Dummy first , and then Wrapped (1, 7) .

What am I doing wrong?

+4
source share
1 answer

RT # 129096: "[BUG] sub, mod_trait: , ". 26 2016 , , , , " , ".

, 10 2016 , :

, " " :

( RT )

, " - "

# perl6-dev , .

+4

Source: https://habr.com/ru/post/1672576/


All Articles