feat(slang): allow runtime require message via Error(string) call#425
Merged
Conversation
41c36de to
95de376
Compare
48aef58 to
53db7dd
Compare
0b3969c to
3781fbc
Compare
3781fbc to
b2775e5
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the Slang lowering path for Solidity require(cond, expr) so non-literal string messages can be evaluated at runtime and emitted through the Error(string) ABI call form.
Changes:
- Allows
requireto accept a runtime message expression instead of rejecting all non-literal messages. - Extends the MLIR builder helper for
sol.requireto accept call operands and the{call}marker. - Adds a lit test covering literal and runtime-message
requirelowering.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
solx-slang/src/ast/contract/function/expression/call/built_in.rs |
Updates require lowering to distinguish no message, literal message, and runtime string expression forms. |
solx-mlir/src/context/builder/mod.rs |
Extends emit_sol_require to pass operands and mark ABI call-style require operations. |
solx-mlir/tests/lit/require_runtime_message.sol |
Adds MLIR checks for literal and runtime require messages. |
8e30a72 to
7d4a37e
Compare
Bumps slang_solidity_v2 to pick up the fix in NomicFoundation/slang#1801, which restores `HexNumberExpression::integer_value()` to parsing the literal text instead of routing through binder typing. Without it, hex literals in address-returning positions panic during lowering with "hex literals always evaluate to integers". Adapts to slang v2 API changes that landed since the previous pin: - `ContractDefinition::compute_abi_with_file_id(file_id)` is gone; the replacement `compute_abi()` derives the file from the contract node. - `CompilationUnit::get_file_ast_root(file_id)` is gone; the replacement flow is `CompilationUnit::file(file_id)` then `File::ast()`.
7d4a37e to
3568062
Compare
abinavpp
approved these changes
May 28, 2026
Contributor
abinavpp
left a comment
There was a problem hiding this comment.
thank you! yea, this is broken in solc :(, but the lowering looks correct iirc
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.
Lowers
require(cond, expr)whereexpris not a string literal. The expression is evaluated at runtime, converted tostring memoryviasol.cast(no-op when the source is already memory), and emitted assol.require %cond, "Error(string)"(%msg : !sol.string<memory>) {call}, mirroring the per-argument type conversion the custom-error revert path uses.Integration test delta (M3B3),
tests/solidity/simple/: