Skip to content

pointers: scope define variables to their in - #317

Merged
gnidan merged 1 commit into
mainfrom
pointers-define-scope
Oct 3, 2026
Merged

gnidan merged 1 commit into
mainfrom
pointers-define-scope

Conversation

@gnidan

@gnidan gnidan commented Oct 3, 2026

Copy link
Copy Markdown
Member

dereference kept the variables of a define after its in finished. They were saved into one map that every later pointer shared, so a define inside one member of a group changed the variables seen by the members after it. For example, in a group whose first member defines slot as slot + 1, a later member that reads slot saw the shifted value instead of the outer one.

This is where it showed up: solc's template for a struct with a string member (the Order struct in the Shop example, from solc #16990) defines slot = slot + 1 inside the string member, so every member after it was decoded one slot too far.

The fix restores the variable map to its state before the define once the in pointer is processed. The schema does not spell out the scoping rule, but variables exist only to build the in pointer, and nothing in the spec says they outlive it. Regions saved by name are not affected, so references such as { ".offset": "array-count" } still work across group members.

The tests cover the minimal group case and a define inside a template referenced from a group member. Includes a changelog entry.

@gnidan
gnidan force-pushed the pointers-define-scope branch from 4c71e00 to 3901b8c Compare October 3, 2026 18:57
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-03 19:39 UTC

@gnidan
gnidan merged commit e39b023 into main Oct 3, 2026
7 checks passed
@gnidan
gnidan deleted the pointers-define-scope branch October 3, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant