feat(slang): state-variable getters, custom errors, and type metadata - #463
Open
hedgar2017 wants to merge 5 commits into
Open
feat(slang): state-variable getters, custom errors, and type metadata#463hedgar2017 wants to merge 5 commits into
hedgar2017 wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Slang-frontend support for Solidity’s auto-generated external getters for public state variables by (1) emitting sol.func getter stubs for supported cases and (2) exposing state-variable selectors to the test harness selector-lookup table, improving compatibility with Solidity tests that call these getters.
Changes:
- Extend
AstEmittermethod-identifier collection to include state-variable getter selectors. - Emit external
viewgettersol.funcs for some public state variables by loading from the computed storage slot and returning the value.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
solx-slang/src/ast/mod.rs |
Adds state-variable signatures/selectors to the method-identifier map returned to the harness. |
solx-slang/src/ast/contract/mod.rs |
Emits MLIR sol.func getter bodies for state variables (currently keyed off ABI “no-input” getters). |
hedgar2017
force-pushed
the
feat-slang-state-var-getters
branch
from
August 6, 2026 13:56
10ae834 to
8e1a543
Compare
hedgar2017
added a commit
that referenced
this pull request
Aug 6, 2026
hedgar2017
force-pushed
the
feat-slang-state-var-getters
branch
from
August 7, 2026 13:38
4281366 to
3cc5f59
Compare
Coverage Summary
|
hedgar2017
force-pushed
the
feat-slang-state-var-getters
branch
3 times, most recently
from
August 7, 2026 14:48
e8b374b to
6371ac5
Compare
hedgar2017
marked this pull request as ready for review
August 7, 2026 14:51
hedgar2017
force-pushed
the
feat-slang-state-var-getters
branch
2 times, most recently
from
August 7, 2026 17:46
105e9e2 to
f05a17e
Compare
PavelKopyl
reviewed
Aug 11, 2026
PavelKopyl
reviewed
Aug 11, 2026
PavelKopyl
reviewed
Aug 11, 2026
PavelKopyl
reviewed
Aug 11, 2026
Adds the getter/ module synthesizing a getter `sol.func` for each public state variable off slang's getter type: scalar (value and reference) reads, keyed mapping/array levels (`sol.map` / `sol.gep` with `no_panic_bounds`), struct leaves with non-returnable members skipped, and constant initializer folds. External getter calls (`c.publicVar(keys)` -> static `sol.ext_call`) and `try` over a getter dispatch through the new `ExternalCallee` classification, which admits functions and public state variables alike. `require(cond, E(..))` lowers custom errors through `sol.require`; a contract namespace delegates value and place access to its members (`C.x = v`, `Library.CONST`); `type(..)` metadata folds to constants: integer min/max, name, interfaceId, and creation/runtime code through `sol.object_code`; error and event `.selector` fold to the selector and topic constants. Immutable and transient getters are loud `unimplemented!` arms. The slang pin moves to the rebased `az-dev-solx-clean`, whose `compute_interface_id` covers only the functions the interface itself declares, matching `type(I).interfaceId`.
A library-qualified callee slipped past the contract-namespace branch into the external classification, which evaluated the library name as a value and panicked on an unrelated invariant. The namespace identifier now dispatches per definition kind, as member access already does.
The getter emission and the ABI method identifiers each re-walked the contract members for the externally visible state variables; the scope owns the full list, so the public subset is collected beside it and lent to both.
hedgar2017
force-pushed
the
feat-slang-state-var-getters
branch
2 times, most recently
from
August 12, 2026 18:03
a8acb11 to
ba5a309
Compare
Leaf::members re-derived which struct members a getter returns, a second copy of the rule slang applies when it builds the getter's return type: the two lists are zipped, so a divergence would silently drop reads. The slang pin moves to the revision exposing `getter_struct_members()`, and the leaf only recovers where those members sit among the declared ones.
hedgar2017
force-pushed
the
feat-slang-state-var-getters
branch
from
August 13, 2026 15:23
ba5a309 to
d67ede1
Compare
hedgar2017
enabled auto-merge
August 13, 2026 15:23
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Aug 13, 2026
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 the contract-surface constructs through the Slang→MLIR pipeline: public state-variable getters, custom-error
require, contract-namespace access, andtype(..)metadata.getter/module synthesizes asol.funcper public variable off slang's getter type — scalar and reference reads, keyed mapping/array levels (sol.map/sol.gep no_panic_bounds), struct leaves with non-returnable members skipped, and constant initializer folds; immutable and transient variables are loudunimplemented!arms.c.publicVar(keys)andtryover a getter classify through the newExternalCallee, which admits functions and public state variables alike and dispatches getters as static calls.require:require(cond, E(..))lowers throughsol.requirewith the error's signature, bare and namespace-qualified alike.C.x = v,Library.CONST).type(..)metadata: integermin/max,name,interfaceId, andcreationCode/runtimeCodethrough the newsol.object_codewrapper..selector(4-byte) and event.selector(32-byte topic) fold to constants, as does.selectoron a getter reference.Tests: 13 consolidated LIT fixtures (8 dual-oracle against
solc --mlir-action=print-init, 5 solx-only); full tester goes 8792 → 9468 passing with zero regressed files.