Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/perl5Public

split bitwise-assignment operators (&=,&.=, etc) don't return lvalues #22412

Closed
@mauke

Description

@mauke

Description
Assignment operators (like= itself, but also+= or>>=) are supposed to return their left operand as an lvalue, which can then be further modified within the same expression. The old combined numeric/string bitwise assignment operators do this, but the new(er) split numeric and string bitwise operators (as provided byuse feature qw(bitwise)) do not.

Steps to Reproduce

$ perl -wle '$_ = 1; ($_ |= 9) ^= 4; print'13$ perl -wle '$_ = "HI"; ($_ |= "") ^= " " x 2; print'hi$ perl -wle 'use feature qw(bitwise); $_ = 1; ($_ |= 9) ^= 4; print'Can't modify numeric bitwise or (|) in numeric bitwise xor (^) at -e line 1, near "4;"Execution of -e aborted due to compilation errors.$ perl -wle 'use feature qw(bitwise); $_ = "HI"; ($_ |.= "") ^.= " " x 2; print'Can't modify string bitwise or (|.) in string bitwise xor (^.) at -e line 1, near "2;"Execution of -e aborted due to compilation errors.

Expected behavior

$ perl -wle '$_ = 1; ($_ |= 9) ^= 4; print'13$ perl -wle '$_ = "HI"; ($_ |= "") ^= " " x 2; print'hi$ perl -wle 'use feature qw(bitwise); $_ = 1; ($_ |= 9) ^= 4; print'13$ perl -wle 'use feature qw(bitwise); $_ = "HI"; ($_ |.= "") ^.= " " x 2; print'hi

v5.40.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp