From 5010a9584cd4d57cde84ee92e6ccc29ed5639daf Mon Sep 17 00:00:00 2001 From: Chris Wanstrath <2+defunkt@users.noreply.github.com> Date: Tue, 25 Nov 2025 15:51:45 -0800 Subject: [PATCH] fix bitwise precedence --- src/parser/node.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/parser/node.ts b/src/parser/node.ts index 7bca39c..48f4956 100644 --- a/src/parser/node.ts +++ b/src/parser/node.ts @@ -380,23 +380,25 @@ export const precedence: Record = { // Nullish coalescing '??': 35, + // Bitwise shifts (lower precedence than addition) + '<<': 37, + '>>': 37, + '>>>': 37, + // Addition/Subtraction '+': 40, '-': 40, + // Bitwise AND/OR/XOR (higher precedence than addition) + 'band': 45, + 'bor': 45, + 'bxor': 45, + // Multiplication/Division/Modulo '*': 50, '/': 50, '%': 50, - // Bitwise - 'band': 45, - 'bor': 45, - 'bxor': 45, - '<<': 45, - '>>': 45, - '>>>': 45, - // Exponentiation (right-associative) '**': 60, }