Skip to content

Fix a compiler crash on an @inline int constant outside the int range - #9314

Merged
cknitt merged 1 commit into
masterfrom
inline-int-overflow
Nov 17, 2026
Merged

cknitt merged 1 commit into
masterfrom
inline-int-overflow

Conversation

@cknitt

@cknitt cknitt commented Nov 17, 2026

Copy link
Copy Markdown
Member

Fixes #9299.

An @inline integer literal outside the 32-bit range crashed the compiler with Failure("Int32.of_string"). It now reports an error at the literal, both for @inline let x = … and for @inline(…) in a signature:

This @inline integer constant is outside the int range (-2147483648 to 2147483647).

I chose an error over warning 107 plus a fallback, because the signature form has no ordinary binding to fall back to.

New tests: two super_errors fixtures, one for each form.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kbf3gHgjnQ6wvmo25twpTJ

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Changelog

🐛 Bug fix

  • An @inline integer constant outside the int range reports an error instead of crashing the compiler.

Semantic Diff

1 commit · Full page

✨ Fix a compiler crash on an @inline int constant outside the int range

fb11b55 · cknitt + Claude · Nov 17, 2026, 19:48 UTC · new

Why

The built-in PPX converted the literal with Int32.of_string and did not catch the failure, so the compiler crashed (#9299).

Diagnostic added (out-of-range @inline int)

@inline let big = 10000000000
let use = () => big

diagnostic

-Fatal error: exception Failure("Int32.of_string")
+This @inline integer constant is outside the int range (-2147483648 to 2147483647).

Fixes #9299

Review

  • Does the same apply to @inline(...) in a signature? Yes, both places use the same check; a fixture covers each.

@cknitt

cknitt commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

@codex review

@cknitt
cknitt marked this pull request as ready for review November 17, 2026 19:53
@cknitt cknitt changed the title Report an error for an @inline int constant outside the int range Fix a compiler crash on an @inline int constant outside the int range Nov 17, 2026
Why:
    The built-in PPX converted the literal with Int32.of_string and did
    not catch the failure, so the compiler crashed (#9299).

Diagnostic added (out-of-range @inline int):
Example:
    @inline let big = 10000000000
    let use = () => big
Before (diagnostic):
    Fatal error: exception Failure("Int32.of_string")
After (diagnostic):
    This @inline integer constant is outside the int range (-2147483648 to 2147483647).

Review: Does the same apply to @inline(...) in a signature? Yes, both places
use the same check; a fixture covers each.

Fixes #9299

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gHgjnQ6wvmo25twpTJ
Signed-off-by: Christoph Knittel <ck@cca.io>
@cknitt
cknitt force-pushed the inline-int-overflow branch from 23b425c to fb11b55 Compare November 17, 2026 19:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T19:55:43.673264Z fb11b55 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: fb11b55b98

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown

✅ Compiler benchmarks

Allocated words

In total: 638,080,855 → 638,081,400 (±0.00%).

Generated projects: 629,808,258 → 629,812,226 (±0.00%).

None of the 265 benchmarks changed by 0.1% or more.

Instructions

In total: 9,209,115,871 → 9,209,577,566 (+0.01%).

None of the 33 benchmarks changed by 0.1% or more.

Output size

In total: 25,874,506 → 25,874,868 (±0.00%).

None of the 13 benchmarks changed by 0.1% or more.

Pull request fb11b55 compared with base 54b923a in this run.

@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.12%. Comparing base (54b923a) to head (fb11b55).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9314   +/-   ##
=======================================
  Coverage   82.12%   82.12%           
=======================================
  Files         456      456           
  Lines       65649    65652    +3     
=======================================
+ Hits        53914    53917    +3     
  Misses      11735    11735           
Files with missing lines Coverage Δ
compiler/frontend/bs_builtin_ppx.ml 90.76% <100.00%> (+0.08%) ⬆️
🚀 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 Nov 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

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

@rescript/belt

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

@rescript/darwin-arm64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: fb11b55

@github-actions

Copy link
Copy Markdown

@cknitt
cknitt enabled auto-merge (squash) November 17, 2026 20:09
@cknitt
cknitt merged commit 02a99b7 into master Nov 17, 2026
22 checks passed
@cknitt
cknitt deleted the inline-int-overflow branch November 17, 2026 20:16
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.

@inline integer constant outside the int32 range crashes the compiler

2 participants