Skip to content

fix(javascript): project class definition-time effects through getters - #9233

Closed
SahinurDEV wants to merge 2 commits into
morluto:mainfrom
SahinurDEV:fix/getter-class-definition-effects
Closed

SahinurDEV wants to merge 2 commits into
morluto:mainfrom
SahinurDEV:fix/getter-class-definition-effects

Conversation

@SahinurDEV

Copy link
Copy Markdown
Contributor

Summary

Fixes #9229. Getter bodies that return a class (or object method) whose computed key or extends expression writes through this were 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:

const box = { x: 1, get trigger() { return class { [(this.x = 2, 'key')]() {} }; } };
box.trigger;
return box.x;

and the superclass-expression variant, Node returns 2 while analysis retained literal 1. Direct writes in the getter remain unknown; writes inside uninvoked method bodies correctly keep literal 1.

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:

  1. 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.
  2. GetterResultWalker.#ownsThis — walk past a class/method when arriving via heritage or a computed key so this inside 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

  • Semantic owner and earliest changed stage: JavaScript semantic getter effect collection / #ownsThis ownership; consumers of export-return shapes and getter-projected mutations.
  • Contribution scope fit and linked maintainer decision: ordinary fix; not applicable.
  • CLI and MCP/tool-catalog contract: same commands; corrected static return facts for affected shapes.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: parser-owned observations only; no new execution.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata / package / installation impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: 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 literal 1 for uninvoked bodies and class-owned static/instance initializers. File now 53 tests, all passing.
  • Base reproduction or other evidence: source-derived from [Bug] Class definition effects inside getters leave stale exported return literals #9229; both halves of the fix are required (collector-only or walker-only leave the new cases failing).
  • User-visible CLI/MCP output (if applicable): analyze-javascript-application export-return-shapes for the affected getters become unknown instead of stale literal 1.
  • Remaining proof gaps: full src/domain/javascript suite 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:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

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 --check on the three touched files — clean.

Compatibility, safety, and release

  • Breaking changes or migration steps: none (stricter uncertainty where a false literal was retained).
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (static JS semantic analysis).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: analysis remains inert; no target execution added.

Author readiness

Human owner: @SahinurDEV

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

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
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-07T04:23:26.248492Z
We couldn’t complete this review. Comment @codex review to try again.
0a742d8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge; both previous findings are addressed.

Summary

The PR fixes stale return facts after a getter defines a class or object method that changes its receiver.

  • Getter results no longer keep stale values after definition-time receiver writes.

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]
Loading

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.
@CassieFox23

Copy link
Copy Markdown
Contributor

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 PR readiness failed on the head.

Results

I ran src/domain/javascript/javascriptSemanticAnalysis.getter_receivers.test.ts from head 257ff8a in a VM.

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
PR head 257ff8a pass: 1 of 1 files, 56 of 56 tests pass: 1 of 1 files, 56 of 56 tests pass: 1 of 1 files, 56 of 56 tests
Same head, old source files from 99db80a fail: 1 of 1 files, 8 failed, 48 passed fail: 1 of 1 files, 8 failed, 48 passed fail: 1 of 1 files, 8 failed, 48 passed
  • The old source files were src/domain/javascript/javascriptSemanticGetterResultWalker.ts and src/domain/javascript/javascriptSemanticMemberMutations.ts.
  • On Node 24.22.1, the 8 failing tests all sit in getter receiver mutation aliases (#1665, #2654).
  • Their names cover class, nested class and object method computed keys. They also cover a superclass expression write.
  • Node 22.23.4 and Node 26.12.1 failed the same tests.
  • The PR changes 3 files against merge base 99db80a: the test file and the 2 source files above.
  • Head 257ff8a is 103 commits behind main 99d00d1.
  • GitHub reports the head as mergeable true, with state unstable.

CI on the head:

  • Workflow runs: CI is completed/success, PR title is completed/success, CodeQL production is completed/skipped, and PR readiness is completed/failure.
  • Check runs: 20 success, 23 skipped and 1 failure.
  • The failed check run is Validate author declaration.
  • The success runs include Source tests, Portable tests, CI required and the 8 Test shard runs.

Not run

  • A probe that runs a bare [this.x = 2], [this.x++] and [this.x] computed key in a class method and an object method, comparing return box.x with node -e.
  • A control for a computed key of a class nested in an uninvoked method, and one for a static [..] key, both missing from src/domain/javascript/javascriptSemanticAnalysis.getter_receivers.test.ts.
  • A merge with current main, 99d00d1.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 257ff8a / 99db80a (merge base with main)
  • Red run: 257ff8a with the changed source files from 99db80a
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1
Commands
npm 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 🦊

gensokyo-dev added a commit that referenced this pull request Nov 14, 2026
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]>
N0zoM1z0 pushed a commit that referenced this pull request Nov 14, 2026
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]>
@N0zoM1z0

Copy link
Copy Markdown
Collaborator

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.

@N0zoM1z0 N0zoM1z0 closed this Nov 14, 2026
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Class definition effects inside getters leave stale exported return literals

4 participants