Skip to content

feat(slang): encode require string literal message#346

Merged
hedgar2017 merged 1 commit intomainfrom
feat-slang-require-message
Apr 25, 2026
Merged

feat(slang): encode require string literal message#346
hedgar2017 merged 1 commit intomainfrom
feat-slang-require-message

Conversation

@hedgar2017
Copy link
Copy Markdown
Contributor

@hedgar2017 hedgar2017 commented Apr 20, 2026

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, causing require reverts to lose the error reason.

Newly passing tests:

  • tests/solidity/simple/conditional/require.sol (all)

@hedgar2017 hedgar2017 added the ci:slang Trigger slang unit tests on PR label Apr 20, 2026
@hedgar2017 hedgar2017 requested a review from Copilot April 20, 2026 07:09
@hedgar2017 hedgar2017 self-assigned this Apr 20, 2026
@hedgar2017 hedgar2017 marked this pull request as draft April 20, 2026 07:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 into emit_require.
  • Extend the MLIR builder API for emit_sol_require to accept a msg: &str and set the RequireOperation’s msg attribute.
  • 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.

Comment thread solx-mlir/src/context/builder/mod.rs Outdated
Comment thread solx-slang/src/ast/contract/function/expression/call/mod.rs Outdated
Copy link
Copy Markdown
Contributor

@abinavpp abinavpp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@hedgar2017 hedgar2017 force-pushed the replace-type-cache-with-fields branch from b5bb1f9 to 7510055 Compare April 20, 2026 13:20
@hedgar2017 hedgar2017 marked this pull request as ready for review April 21, 2026 11:31
Base automatically changed from replace-type-cache-with-fields to main April 21, 2026 18:53
@hedgar2017 hedgar2017 force-pushed the feat-slang-require-message branch from 6bbcc63 to 7d874b0 Compare April 23, 2026 04:22
@hedgar2017 hedgar2017 enabled auto-merge April 23, 2026 04:23
@hedgar2017 hedgar2017 force-pushed the feat-slang-require-message branch 8 times, most recently from 921ffc9 to 0816faf Compare April 25, 2026 08:56
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.
@hedgar2017 hedgar2017 force-pushed the feat-slang-require-message branch from 0816faf to 22c94ab Compare April 25, 2026 08:59
@hedgar2017 hedgar2017 added this pull request to the merge queue Apr 25, 2026
Merged via the queue into main with commit d65c000 Apr 25, 2026
50 checks passed
@hedgar2017 hedgar2017 deleted the feat-slang-require-message branch April 25, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:slang Trigger slang unit tests on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants