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

Cannot assign to $_ in a statement_mod 'for' loop in Rakudo #3181

Closed
p6rt opened this issue Jul 5, 2013 · 4 comments
Closed

Cannot assign to $_ in a statement_mod 'for' loop in Rakudo #3181

p6rt opened this issue Jul 5, 2013 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Jul 5, 2013

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

Searchable as RT118769$

@p6rt
Copy link
Author

p6rt commented Jul 5, 2013

From @masak

<masak> n​: my @​x = <& a& &b>; s​:g/\&/\\\&/ for @​x; say @​x
<camelia> niecza v24-86-g39ab531​: OUTPUT«\& a\& \&b␤»
<masak> r​: my @​x = <& a& &b>; s​:g/\&/\\\&/ for @​x; say @​x
<masak> I expect to be able to change those things in an array. is
Rakudo wrong and Niecza right?
<masak> rn​: my @​x = <& a& &b>; for @​x { s​:g/\&/\\\&/ }; say @​x
<camelia> rakudo 29fb2b, niecza v24-86-g39ab531​: OUTPUT«\& a\& \&b␤»
<masak> $_ should be 'is rw' both in a normal for loop and in a
statement_mod for loop, right?
<jnthn> right
* masak submits rakudobug
<masak> r​: my @​x = <x x x>; $_ = 'foo' for @​x; say @​x
<camelia> rakudo 29fb2b​: OUTPUT«Cannot assign to a readonly variable
or a value␤ in block at /tmp/vbd0908EfA​:1␤␤»
<masak> n​: my @​x = <x x x>; $_ = 'foo' for @​x; say @​x
<camelia> niecza v24-86-g39ab531​: OUTPUT«foo foo foo␤»

@p6rt
Copy link
Author

p6rt commented Oct 22, 2014

From @usev6

The two forms of the "for" loop now behave the same​:

$ perl6 -e 'my @​x = <& a& &b>; for @​x { s​:g/\&/\\\&/ }; say @​x'
\& a\& \&b

$ perl6 -e 'my @​x = <& a& &b>; s​:g/\&/\\\&/ for @​x; say @​x'
\& a\& \&b

I added two tests to S04-statement-modifiers/for.t with commit Raku/roast@82d502c355.

I'm closing this ticket now.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 22, 2014

From @usev6

The two forms of the "for" loop now behave the same​:

$ perl6 -e 'my @​x = <& a& &b>; for @​x { s​:g/\&/\\\&/ }; say @​x'
\& a\& \&b

$ perl6 -e 'my @​x = <& a& &b>; s​:g/\&/\\\&/ for @​x; say @​x'
\& a\& \&b

I added two tests to S04-statement-modifiers/for.t with commit Raku/roast@82d502c355.

I'm closing this ticket now.

@p6rt p6rt closed this as completed Oct 22, 2014
@p6rt
Copy link
Author

p6rt commented Oct 22, 2014

@usev6 - Status changed from 'new' 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