Repository navigation
fix: return the right exit code from lean on 32-bit targets - #16137
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
How this was tested:
|
basvandijk
marked this pull request as ready for review
October 31, 2026 10:58
hargoniX
approved these changes
Nov 2, 2026
hargoniX
enabled auto-merge
November 2, 2026 08:44
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.
This PR fixes the exit code of
leanon 32-bit targets such as WebAssembly (wasm32) and i386 after options like--version,--helpand--deps, after an unknown option or an invalid argument, when called without a file name, and after--run. In these casesleanexited with a code derived from a heap address instead of 0, 1 or the exit code of the program'smain; a run that processes a file without--runwas not affected, because it ends withIO.Process.exit.leangets these codes asUInt32values from Lean code: as the error ofLean.ShellOptions.process(since #11434) and as the result ofLean.shellMain.src/util/shell.cppread both withunbox, the second throughget_io_scalar_result<uint32>fromsrc/util/io.h. On 32-bit targets a boxedUInt32is a heap object rather than a scalar, sounboxreturned half its address. This PR reads both withunbox_uint32, as the C code that the compiler generates for amainthat returnsUInt32does, and replacesget_io_scalar_result, which had no other use, withget_io_uint32_result. On 64-bit targetsunbox_uint32is the same asunbox.This PR adds no test:
tests/misc/lean_version.sh,lean_help.shandlean_ghash.shalready check that--version,--helpand--githashexit with 0, but CI runs them only on 64-bit targets, where the old code works. TheWeb Assemblyjob that #16135 re-enables runs six other tests.Claude Code, an AI coding assistant, helped with the investigation, the change, the testing and this description. I reviewed and checked them.
Closes #16136
🤖 Generated with Claude Code