Skip to content

Implement assigning xor (^^=) operator #23242

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

Merged
merged 1 commit into from
May 5, 2025
Merged

Conversation

leonerd
Copy link
Contributor

@leonerd leonerd commented May 2, 2025

When I added '^^' I forgot to implement or test the assigning version of it.

Also it seems pp_xor had the left and right arguments round the wrong way; but until the asymmetry introduced by this change nobody had noticed before. This is now fixed.

(I should write the perldelta)

(fixes #23238)

@pjcj
Copy link
Contributor

pjcj commented May 2, 2025

Probably need to update the Assignment Operators section in perlop too?

@leonerd leonerd added the squash-before-merge Author must squash the commits down before merging to blead label May 2, 2025
@leonerd leonerd removed the squash-before-merge Author must squash the commits down before merging to blead label May 2, 2025
@leonerd
Copy link
Contributor Author

leonerd commented May 2, 2025

Thoughts from PTS is that we'd like to merge this soon, so it can be tested and included in 5.41.13 - if anyone wants to review?

@jkeenan
Copy link
Contributor

jkeenan commented May 2, 2025

Thoughts from PTS is that we'd like to merge this soon, so it can be tested and included in 5.41.13 - if anyone wants to review?

Does the fact that you refer to a development release '5.41.13' mean that we are no longer aiming to issue a production release '5.42.0' on May 20?

If so, I think a revision of the release schedule should be discussed on the Perl 5 Porters list.

@leonerd
Copy link
Contributor Author

leonerd commented May 2, 2025

I believe the impression I got from the PSC folks yesterday was that a .13 seemed suggested soon, yes. But maybe @ap @haarg @book can clarify?

Copy link
Contributor

@mauke mauke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assignment operators are supposed to return their LHS as an lvalue:

$ ./perl -Ilib -wE 'my $x; my $y = 1; ($x ||= $y) = 42; say $x'
42

But:

$ ./perl -Ilib -wE 'my $x; my $y = 1; ($x ^^= $y) = 42; say $x'
Can't modify logical xor in list assignment at -e line 1, near "42;"
Execution of -e aborted due to compilation errors.

When I added '^^' I forgot to implement or test the assigning version of
it.

Also it seems `pp_xor` had the left and right arguments round the wrong
way; but until the asymmetry introduced by this change nobody had
noticed before. This is now fixed.

Also adds `B::Deparse` support for the new assigning xor operator
@leonerd
Copy link
Contributor Author

leonerd commented May 4, 2025

Ahyes. Lvalue context now fixed:

$ ./perl -Ilib -wE 'my $x; my $y = 1; ($x ^^= $y) = 42; say $x'
42

@leonerd leonerd merged commit 29cc805 into Perl:blead May 5, 2025
33 checks passed
@leonerd leonerd deleted the assigning-xor branch May 5, 2025 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

^^= is not implemented
5 participants