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

[JVM] Methods return containerized attribute values #1572

Open
zoffixznet opened this issue Feb 26, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@zoffixznet
Copy link
Contributor

commented Feb 26, 2018

Originally spotted here: d5baa03#commitcomment-27783688

On Moar, the returned value of methods that aren't is rw is not containerized, but on JVM it is:

<Zoffix_> r: use nqp; class Foo { has $.bar; method z { $!bar } }; dd nqp::iscont(Foo.new.z)
<camelia> rakudo-moar eb0649221: OUTPUT: «0␤»
<camelia> ..rakudo-jvm a92950fb4: OUTPUT: «1␤»

<Zoffix_> r: use nqp; class Foo { has $.bar; method z is rw { $!bar } }; dd nqp::iscont(Foo.new.z)
<camelia> rakudo-jvm a92950fb4, rakudo-moar eb0649221: OUTPUT: «1␤»

Same happens with plain variables:

<Zoffix_> r: use nqp; class Foo { has $.bar; method z { my $bar } }; dd nqp::iscont(Foo.new.z)
<camelia> rakudo-jvm a92950fb4: OUTPUT: «1␤»
<camelia> ..rakudo-moar eb0649221: OUTPUT: «0␤»

<Zoffix_> r: use nqp; class Foo { has $.bar; method z is rw { my $bar } }; dd nqp::iscont(Foo.new.z)
<camelia> rakudo-jvm a92950fb4, rakudo-moar eb0649221: OUTPUT: «1␤»

Note that there's a special circumstance—and I'm not quite sure if it's a bug or not. The Proxy returned from a method shows up as iscont even for non-is rw methods and and if the JVM fix is to merely to nqp::decont the value, it'd remove the Proxy.

<Zoffix_> r: use nqp; class Foo { method z { Proxy.new: :STORE{$^a, $^b;Nil}, :FETCH{$^a;Nil} } }; dd nqp::iscont(Foo.new.z)
<camelia> rakudo-jvm a92950fb4, rakudo-moar eb0649221: OUTPUT: «1␤»
@usev6

This comment has been minimized.

Copy link
Contributor

commented Jan 19, 2019

It looks like this has been fixed in the meantime. On JVM the returned value of methods that aren't is rw is not containerized anymore:

$ ./perl6-j -e 'use nqp; class Foo { has $.bar; method z { $!bar } }; dd nqp::iscont(Foo.new.z)'
0
$ ./perl6-j -e 'use nqp; class Foo { has $.bar; method z { my $bar } }; dd nqp::iscont(Foo.new.z)'
0

I don't know which commit fixed it and I'm not patient enough to bisect this on the JVM backend.

Also, I'm not sure whether this merits a test (and if so, where it should go to: roast or rakudo).

@usev6

This comment has been minimized.

Copy link
Contributor

commented Jan 19, 2019

If I'm not mistaken, the note from @zoffixznet about Proxy returned from a method showing up as iscont even for non-is rw methods is related to this issue: #2113. This was a bug that was fixed for 6.d with commit 7d37f9a.

So, could this issue be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.