Skip to content

Fix operator precedence values to match MDN specification#343

Merged
brianmhunt merged 1 commit into
mainfrom
pc/342-parser-wrong-operator-precedence
Apr 20, 2026
Merged

Fix operator precedence values to match MDN specification#343
brianmhunt merged 1 commit into
mainfrom
pc/342-parser-wrong-operator-precedence

Conversation

@phillipc
Copy link
Copy Markdown
Member

Summary

Corrects operator precedence values in packages/utils.parser/src/operators.ts to match the MDN Operator Precedence table.

What changed

The precedence constants were using an outdated numbering that diverged from MDN's current 18→1 scale. Key fixes:

  • Bitwise operators were in reversed order: | (12) > ^ (11) > & (10) — now correctly & (7) > ^ (6) > | (5)
  • Relational/equality operators overlapped with bitwise: comparison and bitwise shared precedence levels 10–11 — now properly separated (relational 9, equality 8, bitwise 7/6/5)
  • All values shifted to match MDN's scale: member access 19→17, prefix 16→14, exponent 15→13, multiplicative 14→12, additive 13→11, logical AND 6→4, logical OR 5→3, arrow 1→2, comma 2→1
  • Function-level equality operators (looseEqual, etc.) updated from precedence 10 to 8

Verification

All 404 parser tests pass. Full suite (5371 tests) passes.

@phillipc phillipc linked an issue Apr 20, 2026 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 20, 2026

Warning

Rate limit exceeded

@phillipc has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 23 minutes and 19 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 23 minutes and 19 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c116c37d-5bc6-4f6c-93ef-95a7034158e5

📥 Commits

Reviewing files that changed from the base of the PR and between d823f22 and 3e7a37a.

📒 Files selected for processing (1)
  • packages/utils.parser/src/operators.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pc/342-parser-wrong-operator-precedence

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@phillipc phillipc requested a review from brianmhunt April 20, 2026 18:36
@brianmhunt brianmhunt merged commit aaf3a03 into main Apr 20, 2026
9 checks passed
@brianmhunt brianmhunt deleted the pc/342-parser-wrong-operator-precedence branch April 20, 2026 18:42
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.

Parser: Wrong operator precedence

2 participants