Repository navigation
vm, compiler: scope with objects to the frame and block that pushed them - #719
Merged
Merged
Conversation
The with-object stack was VM-global and only popped on normal exit from a with body, so objects leaked past return, throw, break, continue, catch and generator suspension, callees saw their callers' with objects (dynamic scoping), and `with (primitive)` skipped the push but still popped the enclosing with's object. Each entry now records the frame depth that pushed it. A frame sees only its own entries plus those its closure captured lexically; entries of exited frames are dropped before the next frame push. A new OpTruncateWith drops a frame's entries at loop break landings, before continue, and at catch/finally entry. Generators and async functions save their frame's entries on suspend and re-push them on resume. Primitives are pushed as their ToObject wrappers so push and pop stay balanced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nooga
force-pushed
the
fix/with-stack-frame-scope
branch
from
October 17, 2026 21:10
65b4b3e to
d4a092e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The with-object stack was VM-global and was only popped when a
withbody exited normally. That caused several bugs:return,throw,break,continue,catchand generator suspensionwith (primitive)skipped the push but still popped the enclosing with's objectFix
with_stack.go).OpTruncateWith Ndrops a frame's entries at loop break landings, beforecontinue, and at catch/finally entry. It is emitted only in functions that contain awith.Known gap (marked FIXME): a
continuerouted through afinallyleaves the with objects between the try and the loop pushed until the loop exits.Testing
tests/scripts/with_stack_frame_scope.ts.TestScriptsis green.language+built-ins, vs main): +2 in language (S13.2.2_A19_T6/T8), no regressions. The built-ins diff showed +4 URI tests; these are timing flakes.🤖 Generated with Claude Code