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

Subtle action-at-a-distance bond broken after seemingly innocent reading operation on array created with Array.new in Rakudo #2669

Closed
p6rt opened this issue Mar 13, 2012 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Mar 13, 2012

Migrated from rt.perl.org#111720 (status was 'resolved')

Searchable as RT111720$

@p6rt
Copy link
Author

p6rt commented Mar 13, 2012

From @masak

<felher> After i had a problem with a program i golfed down the issue
for quite some time. But i don't get why the two golfed-down
one-liners produce different output​:
<felher> nom​: my $x; my @​a = 1,2; $x = Array.new(@​a) => 'x';
$x.key[0]; @​a.pop(); say $x;
<p6eval> rakudo bd6742​: OUTPUT«[1, 2] => "x"␤»
<felher> nom​: my $x; my @​a = 1,2; $x = Array.new(@​a) => 'x'; @​a.pop(); say $x;
<p6eval> rakudo bd6742​: OUTPUT«[1] => "x"␤»
<felher> Might this be a bug?
<moritz> the difference is just the $x.key[0]; in sink context, right?
<felher> moritz​: yes
<moritz> probably is a bug, yes
<felher> Ah, okay. This was quite funny to debug, since everytime i
added debugging-output everything worked (because i printed it). And
everytime i deleted the print statements for debugging it failed again
:)
<masak> felher++ # nice golf!
<masak> felher​: should I submit it?
<felher> masak​: sure. Press your "masak submits rakudobug"-Button.
* masak submits rakudobug
<felher> masak​: you do have that button, don't you?
* masak smiles mysteriously
< felher> :D
<moritz> nom​: my @​a = 1,2; my $x = @​a => 'x'; @​a.pop(); say $x;
<p6eval> rakudo bd6742​: OUTPUT«[1] => "x"␤»
<masak> nom​: my @​a = 1,2; my $x = @​a => 'x'; $x.key[0]; @​a.pop(); say $x;
<p6eval> rakudo bd6742​: OUTPUT«[1] => "x"␤»
<masak> so Array.new is a necessary component of it all.
<masak> so Array.new is a necessary component of it all.
<jnthn> ah
<jnthn> I guess Array.new probably ain't exercised a great deal
<moritz> aye

@p6rt
Copy link
Author

p6rt commented Jun 18, 2015

From @usev6

This bug is still present. I added a test (fudged 'todo') to S32-array/pop.t with commit Raku/roast@046ad7e7e4

1 similar comment
@p6rt
Copy link
Author

p6rt commented Jun 18, 2015

From @usev6

This bug is still present. I added a test (fudged 'todo') to S32-array/pop.t with commit Raku/roast@046ad7e7e4

@p6rt
Copy link
Author

p6rt commented Jun 18, 2015

@usev6 - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 2, 2015

From @usev6

Post-GLR the read operation with $x.key[0] isn't necessary to get the buggy behaviour​:

< bartolin> m​: my $x; my @​a = 1,2; $x = Array.new(@​a) => 'x'; @​a.pop(); say $x; # is that change with glr known/wanted
<+camelia> rakudo-moar e6f360​: OUTPUT«1 => x␤»
< GLRelia> rakudo-moar a6bb0b​: OUTPUT«[1 2] => x␤»
< bartolin> m​: my $x; my @​a = 1,2; $x = @​a => 'x'; @​a.pop(); say $x;
<+camelia> rakudo-moar e6f360​: OUTPUT«1 => x␤»
< GLRelia> rakudo-moar a6bb0b​: OUTPUT«[1] => x␤»

1 similar comment
@p6rt
Copy link
Author

p6rt commented Sep 2, 2015

From @usev6

Post-GLR the read operation with $x.key[0] isn't necessary to get the buggy behaviour​:

< bartolin> m​: my $x; my @​a = 1,2; $x = Array.new(@​a) => 'x'; @​a.pop(); say $x; # is that change with glr known/wanted
<+camelia> rakudo-moar e6f360​: OUTPUT«1 => x␤»
< GLRelia> rakudo-moar a6bb0b​: OUTPUT«[1 2] => x␤»
< bartolin> m​: my $x; my @​a = 1,2; $x = @​a => 'x'; @​a.pop(); say $x;
<+camelia> rakudo-moar e6f360​: OUTPUT«1 => x␤»
< GLRelia> rakudo-moar a6bb0b​: OUTPUT«[1] => x␤»

@p6rt
Copy link
Author

p6rt commented Sep 13, 2015

From @niner

The current behavior is correct due to the one item rule. Array.new(@​a) essentially creates a copy of @​a. Thus changing @​a will not affect the new array.

@p6rt
Copy link
Author

p6rt commented Sep 13, 2015

@niner - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant