Open teodesian opened 1 year ago
The base operators for each of the assignment operators you've mentioned are all scalar operators - they don't operate on lists, so both the assigned to slice and the right argument are evaluated in scalar context.
This would be a new feature rather than a bug fix.
Description Hash slice value modifications with transformative assignment operators (
+=, -=, *=, /=,
) only modify the value of the last sliced key.Concatenative and logic assignment (
.=, &=
, etc) also appear to exhibit this behavior. I suspect regex comparisons do as well, but have not checked this.What is most concerning to me is that undefined-or and or-assignment (
//=, ||=
) also fail in this fashion. This could allow much more flexibility/simplicity in performing hash merges if it modified all the relevant values.I assume the cause is similar to that of #20537, but filing separately in case this is not true. Given the oddly specific actual behavior here, I suspect something is relying on this behavior in non-obvious ways.
I discovered this while attempting to
List::Util::reduce
an array of hashes which had a number of keys whos values needed summing. Slice assign seemed the most straightforward way to do this.Steps to Reproduce
Actual behavior
Expected behavior
Perl configuration