Hi!

By playing with slangs I stumbled upon pretty confusing issue. I have a module 
with a test slang which looks like this:

     class My::Metamodel::MyHOW is Metamodel::ClassHOW {
         method compose (|) {
             note "My compose";
             nextsame;
         }
     }

     sub EXPORT {
         use nqp;
         use NQPHLL:from<NQP>;

         my role MySlang {
             token package_declarator:sym<myclass> {
                 :my $*OUTERPACKAGE := self.package;
                 :my $*PKGDECL := 'myclass';
                 :my $*LINE_NO := HLL::Compiler.lineof(self.orig(), 
self.from(), :cache(1));
                 <sym><.kok>
                 <package_def>
                 <.set_braid_from(self)>
             }
         }

         my role MyActions {
             method package_declarator:sym<myclass>(Mu $/) {
                 $/.make( nqp::atkey(nqp::findmethod($/, 'hash')($/), 
'package_def').ast );
             }
         }
         $ = $*LANG.refine_slang( 'MAIN', MySlang, MyActions );
         $*LANG.set_how('myclass', My::Metamodel::MyHOW);
         {}
     }

And when it's used in a script:

     use lib '.';
     use myslang;

     myclass My {
         method foo { say "!foo" }
     }

     My.new.foo;

everything works as expected, I get this output:

    My compose
    !foo

Then I define a module smodule.pm6:

     use myslang;

     myclass Foo {
     }

And load it dynamically with 'require':

    require ::('smodule');

only to get this:

    My compose
    ===SORRY!===
    Missing serialize REPR function for REPR MVMContext (BOOTContext)

Now I wonder if it's a bug or I'm missing a thing or two in what I'm doing? So 
far, basic guidelines of adding a new package type were taken from World.nqp 
add_package_declarator method which does some extra work some of which is 
clearly not needed in my case; and some perhaps necessary but I don't 
understand it yet.

Best regards,
Vadim Belman

Reply via email to