Skip to content

feat(slang): add assert built-in#345

Merged
hedgar2017 merged 1 commit intomainfrom
feat-slang-assert-builtin
Apr 23, 2026
Merged

feat(slang): add assert built-in#345
hedgar2017 merged 1 commit intomainfrom
feat-slang-assert-builtin

Conversation

@hedgar2017
Copy link
Copy Markdown
Contributor

@hedgar2017 hedgar2017 commented Apr 20, 2026

Wire up assert(condition) as a built-in function dispatch in CallEmitter.

Previously, assert() calls fell through to resolve_function and failed with "undefined function: assert".

Newly passing tests:

  • tests/solidity/simple/fuzzed/boolean_assert.sol
  • tests/solidity/simple/fuzzed/boolean_assert1.sol

@hedgar2017 hedgar2017 added the ci:slang Trigger slang unit tests on PR label Apr 20, 2026
@hedgar2017 hedgar2017 self-assigned this Apr 20, 2026
@hedgar2017 hedgar2017 requested a review from Copilot April 20, 2026 04:22
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 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 assert built-in detection in CallEmitter::emit_function_call and lower it via a new emit_assert helper.
  • Introduce Builder::emit_sol_assert to append a sol.assert operation.

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.

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
Base automatically changed from replace-type-cache-with-fields to main April 21, 2026 18:53
Wire up `assert(condition)` as a built-in function dispatch in CallEmitter,
emitting `sol.assert` via a new `emit_sol_assert` builder method.
@hedgar2017 hedgar2017 force-pushed the feat-slang-assert-builtin branch from 60f0649 to 484ce81 Compare April 23, 2026 04:17
@hedgar2017 hedgar2017 enabled auto-merge April 23, 2026 04:17
@hedgar2017 hedgar2017 added this pull request to the merge queue Apr 23, 2026
Merged via the queue into main with commit 5001835 Apr 23, 2026
50 checks passed
@hedgar2017 hedgar2017 deleted the feat-slang-assert-builtin branch April 23, 2026 05:16
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