Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.94k stars 553 forks source link

op.c: treat bitwise-{and,xor,or} assignment as lvalue #22414

Closed mauke closed 2 months ago

mauke commented 3 months ago

Previously, ($x &= $y) += $z was fine (since &= returns an lvalue), but not under feature "bitwise":

Can't modify numeric bitwise and (&) in addition (+) at ...

Similar for ^= and |=.

Extend the lvalue behavior of the old number/string mixed bitwise assignment operators (&= ^= |=) to the new separate bitwise assignment operators available under feature "bitwise" (&= ^= |= &.= ^.= |.=).

Fixes #22412.

sisyphus commented 3 months ago

LGTM

khwilliamson commented 2 months ago

Because it doesn't work on an EBCDIC system. I tried my suggested changes, and it does.

mauke commented 2 months ago

Because it doesn't work on an EBCDIC system. I tried my suggested changes, and it does.

How does it fail on EBCDIC?

I think your suggestion is wrong because I'm trying to test bitwise operations on numbers, but uni_to_native is a string-to-string transformation. And numeric operations shouldn't depend on character sets anyway.