Skip to content

fix: detect >> and << in isBitwiseOperator#2460

Open
jorgsowa wants to merge 1 commit intoprettier:mainfrom
jorgsowa:fix/is-bitwise-operator-shift-detection
Open

fix: detect >> and << in isBitwiseOperator#2460
jorgsowa wants to merge 1 commit intoprettier:mainfrom
jorgsowa:fix/is-bitwise-operator-shift-detection

Conversation

@jorgsowa
Copy link
Collaborator

Used array index access (bitshiftOperators[operator]) instead of .includes(), so >> and << were never recognized as bitwise operators.

This caused missing clarifying parentheses when shift operators appeared as the parent in a binary expression, e.g. $a + $b >> $c was printed instead of ($a + $b) >> $c.

Copy link
Collaborator

@czosel czosel left a comment

Choose a reason for hiding this comment

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

Nice find!

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.

2 participants