feat(slang): encode require string literal message#346
Merged
hedgar2017 merged 1 commit intomainfrom Apr 25, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR restores require(cond, "msg") revert reasons by extracting a string literal message from the second require argument (when present) and threading it through to the sol.require op’s msg attribute.
Changes:
- Update Slang call lowering to parse
require(cond[, "msg"])and pass the message intoemit_require. - Extend the MLIR builder API for
emit_sol_requireto accept amsg: &strand set theRequireOperation’smsgattribute. - Add a helper to extract and concatenate simple string literal terminals.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| solx-slang/src/ast/contract/function/expression/call/mod.rs | Extracts a string-literal require message and forwards it into emit_require via a new helper. |
| solx-mlir/src/context/builder/mod.rs | Changes emit_sol_require to accept a message string and emit it into the RequireOperation. |
b5bb1f9 to
7510055
Compare
6bbcc63 to
7d874b0
Compare
921ffc9 to
0816faf
Compare
Extract the string literal from the second argument of require(cond, "msg") and pass it into sol.require's msg attribute. Previously the message was always hardcoded to an empty string.
0816faf to
22c94ab
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.
Extract the string literal from the second argument of
require(cond, "msg")and pass it intosol.require'smsgattribute. Previously the message was always hardcoded to an empty string, causing require reverts to lose the error reason.Newly passing tests:
tests/solidity/simple/conditional/require.sol(all)