Skip to content

feat(slang): state-variable getters, custom errors, and type metadata - #463

Open
hedgar2017 wants to merge 1 commit into
main-slangfrom
feat-slang-state-var-getters
Open

feat(slang): state-variable getters, custom errors, and type metadata#463
hedgar2017 wants to merge 1 commit into
main-slangfrom
feat-slang-state-var-getters

Conversation

@hedgar2017

@hedgar2017 hedgar2017 commented May 28, 2026

Copy link
Copy Markdown
Contributor

Lowers the contract-surface constructs through the Slang→MLIR pipeline: public state-variable getters, custom-error require, contract-namespace access, and type(..) metadata.

  • Public state-variable getters: the getter/ module synthesizes a sol.func per 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 loud unimplemented! arms.
  • External getter dispatch: c.publicVar(keys) and try over a getter classify through the new ExternalCallee, which admits functions and public state variables alike and dispatches getters as static calls.
  • Custom-error require: require(cond, E(..)) lowers through sol.require with the error's signature, bare and namespace-qualified alike.
  • Namespace member access: a contract namespace delegates value and place access to its members (C.x = v, Library.CONST).
  • type(..) metadata: integer min/max, name, interfaceId, and creationCode/runtimeCode through the new sol.object_code wrapper.
  • Selector folds: error .selector (4-byte) and event .selector (32-byte topic) fold to constants, as does .selector on 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.

@hedgar2017 hedgar2017 added the ci:slang Trigger slang unit tests on PR label May 28, 2026
@hedgar2017 hedgar2017 self-assigned this Jun 1, 2026
@hedgar2017
hedgar2017 requested a review from Copilot June 1, 2026 05:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 AstEmitter method-identifier collection to include state-variable getter selectors.
  • Emit external view getter sol.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).

Comment thread solx-slang/src/ast/mod.rs Outdated
Comment thread solx-slang/src/ast/contract/mod.rs Outdated
@hedgar2017
hedgar2017 force-pushed the feat-slang-state-var-getters branch from 10ae834 to 8e1a543 Compare August 6, 2026 13:56
hedgar2017 added a commit that referenced this pull request Aug 6, 2026
@hedgar2017
hedgar2017 changed the base branch from main to main-slang August 6, 2026 13:57
@hedgar2017
hedgar2017 force-pushed the feat-slang-state-var-getters branch from 4281366 to 3cc5f59 Compare August 7, 2026 13:38
@hedgar2017 hedgar2017 changed the title feat(slang): emit external getters for public state variables feat(slang): state-variable getters, custom errors, and type metadata Aug 7, 2026
@hedgar2017
hedgar2017 requested review from a team and Copilot August 7, 2026 13:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 33 out of 34 changed files in this pull request and generated no new comments.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Coverage Summary

Crate Line Coverage Function Coverage
solx 🟢 83.6% 🔴 20.0%
solx-benchmark-converter 🔴 0.0% 🔴 0.0%
solx-codegen-evm 🔴 25.5% 🔴 13.5%
solx-compiler-downloader 🔴 0.0% 🔴 0.0%
solx-core 🔴 38.6% 🔴 47.6%
solx-dev 🔴 2.4% 🔴 3.0%
solx-evm-assembly 🔴 0.0% 🔴 0.0%
solx-mlir 🟡 59.6% 🟡 56.9%
solx-slang 🔴 23.6% 🔴 32.0%
solx-solc-test-adapter 🔴 1.7% 🔴 2.1%
solx-standard-json 🔴 42.8% 🔴 47.7%
solx-tester 🔴 36.5% 🔴 34.3%
solx-utils 🔴 29.7% 🔴 33.3%
solx-yul 🔴 0.0% 🔴 0.0%
Total 🔴 10.9% 🔴 13.1%

Codecov Report | HTML Report | Workflow Run

@hedgar2017
hedgar2017 force-pushed the feat-slang-state-var-getters branch 3 times, most recently from e8b374b to 6371ac5 Compare August 7, 2026 14:48
@hedgar2017
hedgar2017 marked this pull request as ready for review August 7, 2026 14:51
@hedgar2017
hedgar2017 force-pushed the feat-slang-state-var-getters branch from 6371ac5 to 105e9e2 Compare August 7, 2026 14:57
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`.
@hedgar2017
hedgar2017 force-pushed the feat-slang-state-var-getters branch from 105e9e2 to f05a17e Compare August 7, 2026 17:46
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.

2 participants