Skip to content

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

Merged
czosel merged 1 commit intoprettier:mainfrom
jorgsowa:fix/is-bitwise-operator-shift-detection
Mar 23, 2026
Merged

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

Conversation

@jorgsowa
Copy link
Copy Markdown
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
Copy Markdown
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!

@czosel czosel merged commit cf80f5e into prettier:main Mar 23, 2026
14 of 15 checks passed
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