fix bitwise precedence

This commit is contained in:
Chris Wanstrath 2025-11-25 15:51:45 -08:00
parent 4b6f6a127f
commit 5010a9584c

View File

@ -380,23 +380,25 @@ export const precedence: Record<string, number> = {
// Nullish coalescing // Nullish coalescing
'??': 35, '??': 35,
// Bitwise shifts (lower precedence than addition)
'<<': 37,
'>>': 37,
'>>>': 37,
// Addition/Subtraction // Addition/Subtraction
'+': 40, '+': 40,
'-': 40, '-': 40,
// Bitwise AND/OR/XOR (higher precedence than addition)
'band': 45,
'bor': 45,
'bxor': 45,
// Multiplication/Division/Modulo // Multiplication/Division/Modulo
'*': 50, '*': 50,
'/': 50, '/': 50,
'%': 50, '%': 50,
// Bitwise
'band': 45,
'bor': 45,
'bxor': 45,
'<<': 45,
'>>': 45,
'>>>': 45,
// Exponentiation (right-associative) // Exponentiation (right-associative)
'**': 60, '**': 60,
} }