Repository navigation
vm, compiler: give each class evaluation its own private names - #722
Merged
Merged
Conversation
Private names compiled to keys "K:name" per class declaration K, so every evaluation of one class shared them: instances of a second evaluation passed the first one's brand checks. Each class evaluation now runs with a PrivateEnv node for K, pushed by a new OpPushPrivateEnv and popped by OpPopPrivateEnv. Closures created inside the class body capture the node chain, and the class evaluation code sees it through a frame-depth-tagged stack. A private key resolves through the innermost node for its K. The first evaluation keeps the compiled key; later ones get a key suffixed with their evaluation number. Also: - instances get their private methods and accessors before any field initializer runs, as InitializeInstanceElements requires - a Proxy returned from a base constructor stores the derived class's private elements on itself, without consulting its traps Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Part of #560 (class private-name cluster).
Problems
"K:name"keys per class declaration, so every evaluation of the same class shared them. Instances made by one evaluation passed another evaluation's brand checks:c1.access(c2)returned instead of throwing a TypeError.a = this.#m()threw.Fix
PrivateEnvnode for K (newOpPushPrivateEnv/OpPopPrivateEnv).ClosureObject.PrivateEnv).pkg/vm/private_env.go).ProxyObjectgets its own private-element store, which the private ops use without touching the handler.Testing
tests/scripts/class_private_names_per_evaluation.ts.TestScriptsis green.language+built-ins, vs main): +20, no regressions.Five private-related class tests still fail for separate reasons:
decorator-member-expr-private-identifierprivatefieldput-primitive-receiverprivatefieldset-evaluation-order-1privatefieldset-typeerror-10super-access-inside-a-private-method🤖 Generated with Claude Code