Skip to content

programs-react: read variables across a gather - #342

Merged
gnidan merged 3 commits into
mainfrom
inline-variables-reader
Oct 6, 2026
Merged

gnidan merged 3 commits into
mainfrom
inline-variables-reader

Conversation

@gnidan

@gnidan gnidan commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

extractVariablesFromInstruction returned a context's own variables and never looked into its gather when it had them. But all of a context's keys apply, and so do all of a gather's contexts, so a context can say which variables are in scope in more than one place. bugc did exactly that at inlined code (the callee's locals beside a gather whose callee branch held the storage variables), and the debugger demo lost total and calls at every inlined step of weights.bug at O2.

Now the extractor reads every variables list: the context's own and each gathered context's. Only one of a pick's contexts holds, so of a pick it lists only the variables that all of its contexts list alike (the same identifier, declaration and pointer), where before it took the first context with any; picks and gathers nest the same way. Entries for one variable compose into one, as in the two-entry example in the ethdebug/format/program/context/gather schema, but only for the same identifier and declaration (compared by source and range) in the same frame. An entry without a declaration stays apart, since two such entries can be different variables, and facts from different frames are not merged.

bugc now emits one flat list there (#341), but readers should take any valid shape, so this stands on its own.

All of a context's keys apply, and so do all of a `gather`'s
contexts, so the variables at an instruction are every `variables`
list in its context: its own and each gathered context's. The
extractor stopped at the context's own list, so at bugc's inlined code
(the callee's locals beside a gather that held the storage variables)
the storage variables disappeared. Entries for one variable (the same
identifier and declaration, as in the gather schema's example) now
compose into one.
@gnidan
gnidan force-pushed the inline-variables-reader branch from 56d20ce to e3381a3 Compare October 6, 2026 06:51
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-06 14:26 UTC

gnidan added 2 commits October 6, 2026 03:33
Only one of a `pick`'s contexts holds, so of a pick the extractor
lists only the variables that all of its contexts list alike: the same
identifier, declaration and pointer. Entries compose into one only for
the same identifier and declaration (compared by source and range,
whatever the order of keys) in the same frame; an entry without a
declaration stays apart, as one did before.
Of a pick, an entry the contexts agree on keeps its type only where they all give the same type: otherwise the type holds in only one of them.
@gnidan
gnidan merged commit 4d96e44 into main Oct 6, 2026
7 checks passed
@gnidan
gnidan deleted the inline-variables-reader branch October 6, 2026 14:22
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