Repository navigation
fix(javascript): project class definition-time effects through getters - #9233
SahinurDEV wants to merge 2 commits into
Conversation
Computed keys and superclass expressions evaluate against the enclosing getter receiver. Visit those definition-time expressions when collecting accessor effects, and walk past class/method boundaries in #ownsThis when the path arrives from heritage or a computed key so receiver writes are not dropped. Fixes morluto#9229
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The reviewed changes appear safe to merge; both previous findings are addressed. SummaryThe PR fixes stale return facts after a getter defines a class or object method that changes its receiver.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Read a getter] --> B[Collect definition-time expressions]
B --> C[Collect computed-key conversion effects]
C --> D[Resolve the enclosing getter receiver]
D --> E[Invalidate affected return facts]
B --> F[Skip deferred method bodies]
Reviews (3) · Last reviewed commit: "fix(javascript): keep computed definitio..." · Reviewed by Greptile |
Defining a computed class or object member converts its key to a property name, so preserve that coercion escape alongside the key expression walk. Reuse javaScriptComputedDefinitionKey for computed-key ownership in the getter result walker instead of repeating the check.
|
TL;DR: On Node 22.23.4, 24.22.1 and 26.12.1, all 56 tests in the PR's test file passed. With the 2 changed source files swapped back to the merge base, 8 tests failed. The CI check ResultsI ran
CI on the head:
Not run
Test setupCommandsnpm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- src/domain/javascript/javascriptSemanticAnalysis.getter_receivers.test.ts🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊 |
Computed keys and superclass expressions evaluate against the enclosing getter receiver. Visit those definition-time expressions when collecting accessor effects, and walk past class/method boundaries in #ownsThis when the path arrives from heritage or a computed key so receiver writes are not dropped. Fixes #9229 Supersedes #9233 Co-Authored-By: gensokyo-dev <[email protected]>
Computed keys and superclass expressions evaluate against the enclosing getter receiver. Visit those definition-time expressions when collecting accessor effects, and walk past class/method boundaries in #ownsThis when the path arrives from heritage or a computed key so receiver writes are not dropped. Fixes #9229 Supersedes #9233 Co-Authored-By: gensokyo-dev <[email protected]>
|
Thank you for this fix. It landed in #10538 with your authorship kept on the commit (plus review follow-ups noted in the PR), so I'm closing this PR as superseded. |
Summary
Fixes #9229. Getter bodies that return a class (or object method) whose computed key or
extendsexpression writes throughthiswere retaining a stale literal receiver value. Node executes those definition-time expressions against the enclosing getter receiver; REA must invalidate (or correctly update) the exported return fact instead of keeping the pre-write literal.Problem and expected behavior
For fixtures such as:
and the superclass-expression variant, Node returns
2while analysis retained literal1. Direct writes in the getter remain unknown; writes inside uninvoked method bodies correctly keep literal1.Expected: after a definition-time write through the getter receiver, the exported return is unknown (or a correctly justified post-write value), not the obsolete literal
1. Preserve the direct-write and uninvoked-method controls.Change and scope
Two coordinated ownership/collection fixes:
accessorEffectOperands— when walking a nested function/class definition, still visit definition-time expressions (superclass expression; computed keys on class/object methods and fields). Deferred method bodies and class-receiver field initializers remain skipped.GetterResultWalker.#ownsThis— walk past a class/method when arriving via heritage or a computed key sothisinside those expressions is attributed to the enclosing getter receiver.Contribution scope: ordinary fix within the existing JavaScript semantic analysis boundary. Maintainer scope decision: not applicable.
Contract and boundary impact
#ownsThisownership; consumers of export-return shapes and getter-projected mutations.Expected effects:
Evidence and regression coverage
javascriptSemanticAnalysis.getter_receivers.test.ts— 5 cases expect unknown after definition-time receiver writes (computed method/field keys, superclass, nested class key, object method computed key); 6 controls keep literal1for uninvoked bodies and class-owned static/instance initializers. File now 53 tests, all passing.analyze-javascript-applicationexport-return-shapes for the affected getters become unknown instead of stale literal1.src/domain/javascriptsuite and public CLI fixture matrix not re-run in this environment; focused getter-receiver file + project typecheck used. Decorators left out (no Node reference without enablement).Boundary regressions: getter receiver mutation projection through definition-time class/object expressions. Lifecycle: not applicable.
For evidence-bearing changes:
Validation performed
npx vitest run src/domain/javascript/javascriptSemanticAnalysis.getter_receivers.test.ts— 53 passed.node scripts/run-typescript.mjs --noEmit— exit 0.npx oxfmt --checkon the three touched files — clean.Compatibility, safety, and release
Author readiness
Human owner: @SahinurDEV
Before merge
type(scope): outcome.