Skip to content

Fix integer range patterns at int32 boundaries - #8717

Open
fhammerschmidt wants to merge 2 commits into
rescript-lang:masterfrom
fhammerschmidt:fix/integer-range-boundaries
Open

fhammerschmidt wants to merge 2 commits into
rescript-lang:masterfrom
fhammerschmidt:fix/integer-range-boundaries

Conversation

@fhammerschmidt

Copy link
Copy Markdown
Member

Integer range patterns ending at 2147483647 currently generate an exclusive upper-bound comparison against 2147483648, which wraps to -2147483648 in Lambda constants and makes matching values fall through. Use ReScript's signed 32-bit limits when constructing integer match intervals, so the record example in #8716 compiles to x.status >= 2147483645.

Add runtime regressions and generated JavaScript snapshots for both limits, records, tuples, variants, arrays, function results, guards, and switches with distinct actions. This fix is intended for backport to maintenance/12.x and the next v12 patch release alongside #8714.

Fixes #8716.

Validation:

  • make test passes, including formatting, 328 OUnit tests, 561 runtime tests, build fixtures, and 741 documentation examples.
  • All three new regression tests fail with the original compiler and pass with the fix.
  • 2,236,038 differential comparisons across integer switch patterns and 25,124 input values found no regressions or remaining incorrect results.

Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.96%. Comparing base (02976d3) to head (0fd53ff).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8717      +/-   ##
==========================================
+ Coverage   78.95%   78.96%   +0.01%     
==========================================
  Files         474      474              
  Lines       64231    64233       +2     
==========================================
+ Hits        50711    50721      +10     
+ Misses      13520    13512       -8     
Files with missing lines Coverage Δ
compiler/ml/matching.ml 77.86% <100.00%> (+0.10%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new

pkg-pr-new Bot commented Oct 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8717

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@8717

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@8717

@rescript/darwin-x64

npm i https://pkg.pr.new/@rescript/darwin-x64@8717

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@8717

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@8717

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8717

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@8717

commit: 0fd53ff

This branch has not been deployed

No deployments
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.

Integer range patterns ending at 2147483647 generate incorrect JavaScript

1 participant