I saw this issue when I was building Trait::Env, the closest I got to
figuring it out was closure's in phasers in modules seem to get lost in the
compilation process.

But I never figured out a solution I'm afraid.

On Sat, 14 Dec 2019, 22:35 Paul Procacci, <pproca...@gmail.com> wrote:

> Ladies/Gents,
>
> I'm perplexed by the error message as stated in the subject.
> It's quite possible I'm doing it wrong.
> What I'm attempting to do is create an attribute of a class that is a Map
> ... who's value is known at compile time; hence the CHECK phaser.
>
> To produce the error it requires two source files, as merging the class
> and the code that invokes the class doesn't occur in an error:
>
> # File lib/A.pm6
> ------------------------------------
> class A {
>
>         has Map $!pre-compiled = CHECK {
>                 Map.new: dir("data", test => { $_ eq none('.', '..') and
> "data/$_".IO.d })>>.map({
>                                 .basename => .dir>>.map({
>                                         .basename => .dir>>.basename.Set
>                                 })
>                 })
>         };
>
>         method test {
>                 $!pre-compiled.perl.say;
>         }
> }
>
>
> # File: test.pl6
> -------------------------------
> use lib <lib>;
> use A;
>
> my A $x .= new;
> $x.test;
>
>
> % ./test.pl6
> Cannot invoke this object (REPR: Null; VMNull)
>   in block  at xxxx/git-repos/test/lib/Loader.pm6 (Loader) line 31
>   in method test at xxxx/git-repos/test/lib/Loader.pm6 (Loader) line 115
>   in method load at xxxx/git-repos/lib/Loader.pm6 (Loader) line 132
>   in block <unit> at ./test.pl6 line 7
>
>
> As stated earlier, when I merge the class and the initialization logic
> into the same source file and run from there, no error occurs.
>
> Am I doing this wrong?
>
> Thanks,
> Paul Procacci
>
> --
> __________________
>
> :(){ :|:& };:
>

Reply via email to