Skip to content

fix: correct unary minus/plus/tilde precedence#1236

Open
jorgsowa wants to merge 1 commit intomainfrom
fix/unary-minus-precedence
Open

fix: correct unary minus/plus/tilde precedence#1236
jorgsowa wants to merge 1 commit intomainfrom
fix/unary-minus-precedence

Conversation

@jorgsowa
Copy link
Copy Markdown
Collaborator

Unary -, +, and ~ shared the same precedence key as binary - and + (level 15), placing them below * (level 16). This caused -20 * 5 + 10 to be parsed as -(20 * 5 + 10) instead of (-20) * 5 + 10.

Add u-, u+, u~ keys to the precedence table at the ! level (17) and look them up in resolvePrecedence so unary operators correctly bind tighter than multiplicative operators.

@jorgsowa jorgsowa force-pushed the fix/unary-minus-precedence branch from f9de0f1 to 46bb4a0 Compare April 2, 2026 18:20
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.

1 participant