Skip to content

feat(slang): emit external getters for public state variables - #463

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

feat(slang): emit external getters for public state variables#463
hedgar2017 wants to merge 1 commit into
main-slangfrom
feat-slang-state-var-getters

Conversation

@hedgar2017

Copy link
Copy Markdown
Contributor

Solidity auto-generates an external view getter for every public state variable. The Slang frontend was registering only user-defined functions, so any test that read a public state var through its getter selector failed at the test harness's selector-lookup step (selector of the method 'X' not found).

For each ContractMember::StateVariableDefinition, when compute_abi_entry() returns a Function entry with no inputs (scalar getter) the emitter now lays down a sol.func named after the slang canonical signature, carrying the slang-computed selector and View mutability, with a body that loads the corresponding storage slot and returns the value. Indexed getters for T[], mappings, and structs still need sol.gep / sol.map plumbing and are deliberately skipped so the rest of the contract still compiles. AstEmitter::emit also includes state-variable selectors in the method-identifier table the caller hands to the test harness.

tests/solidity/simple -O M3B3 moves from 1896 passed / 3 failed / 307 invalid to 1952 passed / 13 failed / 298 invalid — net +56 passing tests (+10 failed, -9 invalid). The new failures are tests where the getter resolves but some other behavior in the same test mismatches; the bulk of the formerly-invalid selector not found cluster (num, count, text, MY_ADDRESS, oneWei, etc.) now runs and most pass.

@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
hedgar2017 changed the base branch from main to main-slang August 6, 2026 13:57
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