You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A root-program top-level let is not visible to a closure called after the entry frame has popped #786
A closure defined in the root program that reads a module-top-level let reports Undefined variable when it is called after the entry frame has popped — for example from a coroutine a module spawned.
Exposed by #783's fix. Before it, this program failed earlier with Stack underflow, so the binding was never reached.
a top-level fn helper() instead of a let, wrapped and spawned
works (main-fn)
The third row rules out spawning as the cause; the fourth rules out name resolution generally — a top-level function resolves fine, because it lives in the chunk's functions table, which #783's fix now supplies correctly. A top-level let does not.
Diagnosis
Measured: the root program's module_globals is empty — TOKEN is not in it, and neither are the module bindings. So a module-top-level let lives in the entry frame rather than in a namespace that outlives it, and once that frame has popped there is nowhere to look.
This is the neighbourhood of #671 (VM.binding_namespace, "where does this name live"), and probably wants deciding alongside it rather than separately.
Why it is filed rather than fixed
#783 answers which chunk a closure was compiled against. This is which bindings that chunk's top level can still see, which is a different question with a different owner. Fixing it by widening #783's context tuple would be wrong: the tuple already carries the correct (empty) namespace — the binding is simply not in any namespace.
Note the asymmetry it creates today, which is the part worth not shipping silently: a wrapped closure can call a root-level fn but cannot read a root-level let.
Affected versions
Reachable from main at the #783 fix. Present but masked before it.
Activity
Resolve a closure the root program owns from inside a module (#783) (#…
One misplaced line, wearing two faces (#785, #786) (#788)
Release 5.11.0 (#789)