Fix exponentiation precedence for compound exponents - #8550
Merged
cknitt merged 2 commits intoAug 15, 2026
Conversation
Signed-off-by: Christoph Knittel <ck@cca.io>
cknitt
force-pushed
the
codex/fix-exponentiation-precedence
branch
from
August 15, 2026 07:33
58a478c to
c7942db
Compare
cknitt
marked this pull request as ready for review
August 15, 2026 07:39
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #8550 +/- ##
=======================================
Coverage 74.84% 74.84%
=======================================
Files 477 477
Lines 63331 63331
=======================================
Hits 47398 47398
Misses 15933 15933
🚀 New features to boost your workflow:
|
rescript
@rescript/darwin-arm64
@rescript/darwin-x64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
cknitt
force-pushed
the
codex/fix-exponentiation-precedence
branch
from
August 15, 2026 07:54
c7942db to
e94c929
Compare
Signed-off-by: Christoph Knittel <ck@cca.io>
cknitt
force-pushed
the
codex/fix-exponentiation-precedence
branch
from
August 15, 2026 08:25
e94c929 to
254cb45
Compare
cknitt
enabled auto-merge (squash)
August 15, 2026 11:19
fhammerschmidt
approved these changes
Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8549.
Summary
Root cause
The JavaScript printer assigned exponentiation a right-operand precedence of 12, equal to multiplication, division, and modulo. Because parentheses are only added when the required precedence is greater than the child expression's precedence, expressions such as
a ** (b / c)were emitted asa ** b / c, changing their meaning.Requiring precedence 13 on the right preserves compound exponents while retaining JavaScript's right-associative
a ** b ** coutput.Regression history and backport
This regression was introduced by #7153 when float and integer exponentiation switched from
Math.powcalls to native JavaScript**.The change was included in ReScript 12.0.0, so all 12.x releases are affected. This fix should therefore be backported to the maintained 12.x release branch.
Validation
make testmake test-syntaxmake checkformatgit diff --check