[perl #132511] Binary assignment Z+= fails if it's the last thing in for loop
On Mon, 04 Dec 2017 12:31:28 -0800, alex.jakime...@gmail.com wrote: > FWIW it never worked: > https://gist.github.com/Whateverable/d9dbebb0e985a3964845df2c8652cbdf > > On 2017-11-27 17:36:22, comdog wrote: > > I previously asked about this unexpected Z behavior on Stackoverflow > > ( https://stackoverflow.com/q/45001820/2766176 ). > > > > I expected this to change several hash keys at once. It changes no keys: > > > > my $hash = %( > > wallet => 100, > > gave => 0, > > received => 0, > > ); > > > > for ^1 { $hash Z+= <-1 1> } > > > > dd $hash; > > > > I get: > > > > Hash $hash = ${:gave(0), :received(0), :wallet(100)} > > > > If I change that to add another statement it works: > > > > for ^1 { $hash Z+= <-1 1>; True } > > > > It also works if I take out the binary assignment: > > > > for ^1 { $hash = $hash Z+ <-1 1> } Thank you for the report. This is now fixed. Fix: https://github.com/rakudo/rakudo/commit/8a10fc17a319029 Test: https://github.com/perl6/roast/commit/01b59fba66bde1e61
[perl #132511] Binary assignment Z+= fails if it's the last thing in for loop
On Mon, 04 Dec 2017 12:31:28 -0800, alex.jakime...@gmail.com wrote: > FWIW it never worked: > https://gist.github.com/Whateverable/d9dbebb0e985a3964845df2c8652cbdf > > On 2017-11-27 17:36:22, comdog wrote: > > I previously asked about this unexpected Z behavior on Stackoverflow > > ( https://stackoverflow.com/q/45001820/2766176 ). > > > > I expected this to change several hash keys at once. It changes no keys: > > > > my $hash = %( > > wallet => 100, > > gave => 0, > > received => 0, > > ); > > > > for ^1 { $hash Z+= <-1 1> } > > > > dd $hash; > > > > I get: > > > > Hash $hash = ${:gave(0), :received(0), :wallet(100)} > > > > If I change that to add another statement it works: > > > > for ^1 { $hash Z+= <-1 1>; True } > > > > It also works if I take out the binary assignment: > > > > for ^1 { $hash = $hash Z+ <-1 1> } Thank you for the report. This is now fixed. Fix: https://github.com/rakudo/rakudo/commit/8a10fc17a319029 Test: https://github.com/perl6/roast/commit/01b59fba66bde1e61
[perl #132511] Binary assignment Z+= fails if it's the last thing in for loop
FWIW it never worked: https://gist.github.com/Whateverable/d9dbebb0e985a3964845df2c8652cbdf On 2017-11-27 17:36:22, comdog wrote: > I previously asked about this unexpected Z behavior on Stackoverflow > ( https://stackoverflow.com/q/45001820/2766176 ). > > I expected this to change several hash keys at once. It changes no keys: > > my $hash = %( > wallet => 100, > gave => 0, > received => 0, > ); > > for ^1 { $hash Z+= <-1 1> } > > dd $hash; > > I get: > > Hash $hash = ${:gave(0), :received(0), :wallet(100)} > > If I change that to add another statement it works: > > for ^1 { $hash Z+= <-1 1>; True } > > It also works if I take out the binary assignment: > > for ^1 { $hash = $hash Z+ <-1 1> }
Re: [perl #132511] Binary assignment Z+= fails if it's the last thing in for loop
Curious sidenote: when you use [Z+]= it will complain about "useless use of [Z+]= in sink context" and the modifications actually go through. With Z[+=] - which is probably the default parsing of this - it will not complain about useless use, but it also won't Do The Thing.
Re: [perl #132511] Binary assignment Z+= fails if it's the last thing in for loop
Curious sidenote: when you use [Z+]= it will complain about "useless use of [Z+]= in sink context" and the modifications actually go through. With Z[+=] - which is probably the default parsing of this - it will not complain about useless use, but it also won't Do The Thing.
[perl #132511] Binary assignment Z+= fails if it's the last thing in for loop
# New Ticket Created by "brian d foy" # Please include the string: [perl #132511] # in the subject line of all future correspondence about this issue. # https://rt.perl.org/Ticket/Display.html?id=132511 > I previously asked about this unexpected Z behavior on Stackoverflow ( https://stackoverflow.com/q/45001820/2766176 ). I expected this to change several hash keys at once. It changes no keys: my $hash = %( wallet => 100, gave => 0, received => 0, ); for ^1 { $hash Z+= <-1 1> } dd $hash; I get: Hash $hash = ${:gave(0), :received(0), :wallet(100)} If I change that to add another statement it works: for ^1 { $hash Z+= <-1 1>; True } It also works if I take out the binary assignment: for ^1 { $hash = $hash Z+ <-1 1> }