Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with 'with' and attached block #6070

Closed
p6rt opened this issue Feb 13, 2017 · 4 comments
Closed

Problems with 'with' and attached block #6070

p6rt opened this issue Feb 13, 2017 · 4 comments
Labels
JVM Related to Rakudo-JVM

Comments

@p6rt
Copy link

p6rt commented Feb 13, 2017

Migrated from rt.perl.org#130775 (status was 'new')

Searchable as RT130775$

@p6rt
Copy link
Author

p6rt commented Feb 13, 2017

From @usev6

The blockless form of 'with' works as expected on JVM, but there are
some wrong results if there is a block attached to a 'with' condition​:

<bartolin> r​: say 42 with Empty
<camelia> rakudo-moar aac9ef, rakudo-jvm fb4f16​: ( no output )

<bartolin> r​: with Empty { say 42 }
<camelia> rakudo-moar aac9ef​: ( no output )
<camelia> ..rakudo-jvm fb4f16​: OUTPUT«42␤»

Same thing happens with Failure and an actual Failure​:

<bartolin> r​: with Failure.new { say 42 }
<camelia> rakudo-moar aac9ef​: ( no output )
<camelia> ..rakudo-jvm fb4f16​: OUTPUT«42␤»

<bartolin> r​: say 42 with Failure.new
<camelia> rakudo-moar aac9ef, rakudo-jvm fb4f16​: ( no output )

There are fudged tests in S04-statements/with.t for this problem and a
newly added test in S03-smartmatch/any-num.t fails for the same
reason. I'm going to add the number of this ticket to those tests.

@p6rt
Copy link
Author

p6rt commented Feb 14, 2017

From @usev6

I think I know what happens. On MoarVM we call the Perl 6 method 'defined'​: https://github.com/perl6/nqp/blob/ac9a66abad13a7fd3d52b22ba533a9f8436ad1ac/src/vm/moar/QAST/QASTOperationsMAST.nqp#L787

On JVM we test for concreteness (like nqp​::isconcrete would do)​: https://github.com/perl6/nqp/blob/ac9a66abad13a7fd3d52b22ba533a9f8436ad1ac/src/vm/jvm/QAST/Compiler.nqp#L802

And then there are special versions of 'method defined' for Slip and Failure which are missed on JVM when testing for concreteness only​:

$ ./perl6-j -e 'say Empty.defined'
False

$ ./perl6-j -e 'use nqp; say nqp​::isconcrete(Empty)'
1

$ ./perl6-j -e 'say Failure.new.defined'
False

$ ./perl6-j -e 'use nqp; say nqp​::isconcrete(Failure.new)'
1

It looks like the implementation of 'with' needs some refinement on JVM.

@usev6
Copy link

usev6 commented Aug 14, 2021

Just some more context:

usev6 added a commit to usev6/nqp that referenced this issue Aug 15, 2021
... instead of 'isconcrete'.

I'm not sure if my usage of InvokeDynamic is the right way to call
the found 'method defined', but it seems to improve the situation
a lot.

Even if there are still two broken tests (maybe &boolify_instructions
need a tweak, too): This patch makes the other NQP tests for
with/without pass and it helps with two open issues:

* Raku/old-issue-tracker#6070

* rakudo/rakudo#4354
@usev6
Copy link

usev6 commented Aug 22, 2021

The problem has been fixed with Raku/nqp#734.

I've unfudged the tests in roast with Raku/roast@f7810e8018.

@usev6 usev6 closed this as completed Aug 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JVM Related to Rakudo-JVM
Projects
None yet
Development

No branches or pull requests

2 participants