Skip to content

Flow nonlocal writes back to the enclosing function - #84

Merged
SizzleUnrlsd merged 2 commits into
mainfrom
feat/nonlocal-writeback
Sep 5, 2026
Merged

SizzleUnrlsd merged 2 commits into
mainfrom
feat/nonlocal-writeback

Conversation

@SizzleUnrlsd

Copy link
Copy Markdown
Contributor

Summary

The last documented approximation of the analysis, item of #71: a nonlocal write made by a nested function now flows back to the enclosing function.

  • Acceptance tests first (test: define nonlocal writes flowing back to the caller), implementation follows.
  • Lowering. A store to a name the function declares nonlocal also emits a set_nonlocal effect, kept through SSA like set_global. After a direct call to a nested function it defined, the enclosing function emits one nonlocal_result per name that function declares nonlocal and stores it back into its own variable, so SSA sees the rebinding.
  • Summaries. FunctionSummary.nonlocal_writes records, per written name, the parameters and external results the nested function stores into it. The dependence and taint engines evaluate nonlocal_result from the callee's summary and the call's arguments, captured values included, exactly as they evaluate a call's return.
  • Cache. The codec carries nonlocal_writes; the format is bumped to 3 so older entries are recomputed.
  • The test that documented the limit now asserts the flow; the usage guide states the remaining boundary: a nested function passed around and called elsewhere keeps its writes to itself.

Part of #71.

@SizzleUnrlsd SizzleUnrlsd self-assigned this Sep 5, 2026
@SizzleUnrlsd
SizzleUnrlsd merged commit 159d159 into main Sep 5, 2026
10 checks passed
@SizzleUnrlsd
SizzleUnrlsd deleted the feat/nonlocal-writeback branch September 5, 2026 13:02
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