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
--
__________________
:(){ :|:& };: