Cannot invoke this object (REPR: Null; VMNull)

--0000000000003fccb50599b18b89
Content-Type: text/plain; charset="UTF-8"

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

-- 
__________________

:(){ :|:& };:

--0000000000003fccb50599b18b89
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Ladies/Gents,</div><div><br></div><div>I&#39;m perple=
xed by the error message as stated in the subject.</div><div>It&#39;s quite=
 possible I&#39;m doing it wrong.</div><div>What I&#39;m attempting to do i=
s create an attribute of a class that is a Map ... who&#39;s value is known=
 at compile time; hence the CHECK phaser.<br></div><div><br></div><div>To p=
roduce the error it requires two source files, as merging the class and the=
 code that invokes the class doesn&#39;t occur in an error:<br></div><div><=
br></div><div># File lib/A.pm6</div><div>----------------------------------=
--<br></div><div>class A {<br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 has Map $!pre=
-compiled =3D CHECK {<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 Map.new: dir(&quot;data&quot;, test =3D&gt; { $_ eq none(&#39;.&#39;=
, &#39;..&#39;) and &quot;data/$_&quot;.IO.d })&gt;&gt;.map({<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .basename =3D&gt; .dir&gt;&gt;.map({<br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 .basename =3D&g=
t; .dir&gt;&gt;.basename.Set<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 })<br=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 })<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 };<br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 method test {<br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $!pre-compiled.perl=
..say;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br>}<br></div><div><br></div><div><b=
r></div><div># File: test.pl6</div><div>-------------------------------</di=
v><div>use lib &lt;lib&gt;;</div><div>use A;</div><div><br></div><div>my A =
$x .=3D new;<br>$x.test;</div><div><br></div><div><br></div><div>
<div>% ./test.pl6<br>Cannot invoke this object (REPR: Null; VMNull)<br>=C2=
=A0 in block =C2=A0at xxxx/git-repos/test/lib/Loader.pm6 (Loader) line 31<b=
r>=C2=A0 in method test at xxxx/git-repos/test/lib/Loader.pm6 (Loader) line=
 115<br>=C2=A0 in method load at xxxx/git-repos/lib/Loader.pm6 (Loader) lin=
e 132<br>=C2=A0 in block &lt;unit&gt; at ./test.pl6 line 7</div><div><br></=
div><div><br></div><div>As stated earlier, when I merge the class and the i=
nitialization logic into the same source file and run from there, no error =
occurs.</div><div><br></div><div>Am I doing this wrong?<br></div><div><br><=
/div>

</div><div>Thanks,</div><div>Paul Procacci<br></div><div><br>-- <br><div di=
r=3D"ltr" class=3D"gmail_signature" data-smartmail=3D"gmail_signature">____=
______________<br><br>:(){ :|:&amp; };:</div></div></div>

--0000000000003fccb50599b18b89--
0
pprocacci
12/14/2019 10:31:37 PM
perl.perl6.users 1389 articles. 0 followers. Follow

2 Replies
45 Views

Similar Articles

[PageSpeed] 44

--0000000000000d35010599b1b63e
Content-Type: text/plain; charset="UTF-8"

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

--0000000000000d35010599b1b63e
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">I saw this issue when I was building Trait::Env, the clos=
est I got to figuring it out was closure&#39;s in phasers in modules seem t=
o get lost in the compilation process.<div dir=3D"auto"><br></div><div dir=
=3D"auto">But I never figured out a solution I&#39;m afraid.</div></div><br=
><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sat, 1=
4 Dec 2019, 22:35 Paul Procacci, &lt;<a href=3D"mailto:pprocacci@gmail.com"=
>pprocacci@gmail.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quo=
te" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"=
><div dir=3D"ltr"><div>Ladies/Gents,</div><div><br></div><div>I&#39;m perpl=
exed by the error message as stated in the subject.</div><div>It&#39;s quit=
e possible I&#39;m doing it wrong.</div><div>What I&#39;m attempting to do =
is create an attribute of a class that is a Map ... who&#39;s value is know=
n at compile time; hence the CHECK phaser.<br></div><div><br></div><div>To =
produce the error it requires two source files, as merging the class and th=
e code that invokes the class doesn&#39;t occur in an error:<br></div><div>=
<br></div><div># File lib/A.pm6</div><div>---------------------------------=
---<br></div><div>class A {<br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 has Map $!pr=
e-compiled =3D CHECK {<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 Map.new: dir(&quot;data&quot;, test =3D&gt; { $_ eq none(&#39;.&#39;=
, &#39;..&#39;) and &quot;data/$_&quot;.IO.d })&gt;&gt;.map({<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .basename =3D&gt; .dir&gt;&gt;.map({<br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 .basename =3D&g=
t; .dir&gt;&gt;.basename.Set<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 })<br=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 })<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 };<br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 method test {<br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $!pre-compiled.perl=
..say;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br>}<br></div><div><br></div><div><b=
r></div><div># File: test.pl6</div><div>-------------------------------</di=
v><div>use lib &lt;lib&gt;;</div><div>use A;</div><div><br></div><div>my A =
$x .=3D new;<br>$x.test;</div><div><br></div><div><br></div><div>
<div>% ./test.pl6<br>Cannot invoke this object (REPR: Null; VMNull)<br>=C2=
=A0 in block =C2=A0at xxxx/git-repos/test/lib/Loader.pm6 (Loader) line 31<b=
r>=C2=A0 in method test at xxxx/git-repos/test/lib/Loader.pm6 (Loader) line=
 115<br>=C2=A0 in method load at xxxx/git-repos/lib/Loader.pm6 (Loader) lin=
e 132<br>=C2=A0 in block &lt;unit&gt; at ./test.pl6 line 7</div><div><br></=
div><div><br></div><div>As stated earlier, when I merge the class and the i=
nitialization logic into the same source file and run from there, no error =
occurs.</div><div><br></div><div>Am I doing this wrong?<br></div><div><br><=
/div>

</div><div>Thanks,</div><div>Paul Procacci<br></div><div><br>-- <br><div di=
r=3D"ltr" data-smartmail=3D"gmail_signature">__________________<br><br>:(){=
 :|:&amp; };:</div></div></div>
</blockquote></div>

--0000000000000d35010599b1b63e--
0
simon
12/14/2019 10:43:33 PM
What rakudo compiler version do you use? Try 2019.11.

Best regards,
Vadim Belman

> On Dec 14, 2019, at 5:31 PM, Paul Procacci <pprocacci@gmail.com> =
wrote:
>=20
> Ladies/Gents,
>=20
> 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.
>=20
> 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:
>=20
> # File lib/A.pm6
> ------------------------------------
> class A {
>=20
>         has Map $!pre-compiled =3D CHECK {
>                 Map.new: dir("data", test =3D> { $_ eq none('.', '..') =
and "data/$_".IO.d })>>.map({
>                                 .basename =3D> .dir>>.map({
>                                         .basename =3D> =
..dir>>.basename.Set
>                                 })
>                 })
>         };
>=20
>         method test {
>                 $!pre-compiled.perl.say;
>         }
> }
>=20
>=20
> # File: test.pl6
> -------------------------------
> use lib <lib>;
> use A;
>=20
> my A $x .=3D new;
> $x.test;
>=20
>=20
> % ./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
>=20
>=20
> As stated earlier, when I merge the class and the initialization logic =
into the same source file and run from there, no error occurs.
>=20
> Am I doing this wrong?
>=20
> Thanks,
> Paul Procacci
>=20
> --=20
> __________________
>=20
> :(){ :|:& };:
0
vrurg
12/15/2019 6:20:22 PM
Reply: