develooper Front page | perl.perl6.users | Postings from December 2019

Cannot invoke this object (REPR: Null; VMNull)

Thread Next
From:
Paul Procacci
Date:
December 14, 2019 22:32
Subject:
Cannot invoke this object (REPR: Null; VMNull)
Message ID:
CAFbbPuhV3KyXnHyFE=t1nnJ2QXfwvixWwWqX9Dy81u=UfwSGGQ@mail.gmail.com
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

-- 
__________________

:(){ :|:& };:

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About