Repository navigation
[mlir][Sol] Keep the panics of div, mod and constant indexing - #192
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The restored panic semantics lack regression coverage across the affected lowering and optimization paths.
4 open findings
What changed in this PR
Restores legacy Solidity panic behavior for division, modulo, fixed-byte indexing, and fixed-array indexing.
Changes:
- Preserves unused division/modulo operations so zero divisors still panic.
- Cleans fixed-byte indices before bounds checks.
- Adds constant-index bounds checks across storage, memory, and calldata.
| File | Description |
|---|---|
mlir/include/mlir/Dialect/Sol/SolOps.td |
Makes division and modulo non-pure. |
mlir/lib/Conversion/SolToYul/SolToYul.cpp |
Cleans indices and emits unconditional array bounds checks. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
abinavpp
approved these changes
Oct 29, 2026
abinavpp
left a comment
Contributor
There was a problem hiding this comment.
LGTM, thanks! Could you add lit tests here as well?
hedgar2017
force-pushed
the
sol-op-lowering-checks
branch
from
November 5, 2026 14:17
6690a40 to
ef858e0
Compare
Contributor
Author
|
Added the LIT tests. |
An unused sol.div or sol.mod was erased with its division-by-zero panic, a fixed-bytes index was bounds-checked with dirty upper bits, and a constant index past the end of a fixed-size array was never bounds-checked.
hedgar2017
force-pushed
the
sol-op-lowering-checks
branch
from
November 5, 2026 19:21
ef858e0 to
cbcbf89
Compare
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.

Restores three checks legacy solc performs and the Sol lowering dropped:
a % bor uncheckeda / bpanics 0x12 on a zero divisorb[uint8(i)]on fixed bytes checks the cleaned index