feat(slang): add assert built-in#345
Merged
hedgar2017 merged 1 commit intomainfrom Apr 23, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds first-class lowering support for Solidity’s assert(condition) built-in in the slang frontend, emitting the Sol dialect sol.assert op instead of falling through to normal function resolution (which previously produced “undefined function: assert”).
Changes:
- Add
assertbuilt-in detection inCallEmitter::emit_function_calland lower it via a newemit_asserthelper. - Introduce
Builder::emit_sol_assertto append asol.assertoperation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| solx-slang/src/ast/contract/function/expression/call/mod.rs | Detects assert() calls and emits sol.assert with a boolean condition value. |
| solx-mlir/src/context/builder/mod.rs | Adds an MLIR builder helper to construct and append sol.assert. |
b5bb1f9 to
7510055
Compare
Wire up `assert(condition)` as a built-in function dispatch in CallEmitter, emitting `sol.assert` via a new `emit_sol_assert` builder method.
60f0649 to
484ce81
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.
Wire up
assert(condition)as a built-in function dispatch inCallEmitter.Previously,
assert()calls fell through toresolve_functionand failed with "undefined function: assert".Newly passing tests:
tests/solidity/simple/fuzzed/boolean_assert.soltests/solidity/simple/fuzzed/boolean_assert1.sol