[PR #3831] [MERGED] fix(javascript): keep members unknown after a write through a local setter #5933

Closed
opened 2026-10-31 01:10:33 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3831
Author: @kaoru0822-kitauji
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/3312-setter-write-effects


📝 Commits (3)

  • 9a8e239 fix(javascript): keep members unknown after a write through a local setter
  • 6a6f44a fix(javascript): follow nested setters, skip deletes and cache setter keys
  • 8bf89cf fix(javascript): ignore setters replaced by a later data property

📊 Changes

2 files changed (+194 additions, -0 deletions)

View changed files

➕ src/domain/javascript/javascriptSemanticAnalysis.accessor_writes.test.ts (+108 -0)
📝 src/domain/javascript/javascriptSemanticMemberMutations.ts (+86 -0)

📄 Description

Fixes #3312 (setter case; see Remaining for the getter variant)

Root cause

collectSemanticMemberMutationsSteps records state.update = 2 as an ordinary write to path ["update"]. When update is a setter of the binding's own object literal, the assignment runs the setter instead, and the setter may write any member of its receiver (this.value = next). Only /update was invalidated, so the sibling value: 1 stayed a known literal. Static return shapes then showed /value: 1, and compare-javascript-export-shapes reported a no-op setter and a value-writing setter as complete and unchanged.

Change

In the mutation collector, a one-key write whose key names a set accessor on one of the binding's own object-literal initializers (projection []) is recorded with an unknown key ([null]). The existing mutation lattice already turns that into unknown ("This property may have been mutated."). A computed setter key may match any written key, so it counts as matching. Writes to ordinary properties are unchanged and keep their sibling literals.

Validation

The issue's public repro (analyze-javascript-application on both fixtures, then compare-javascript-export-shapes):

main this PR
left (no-op setter) /value literal 1 unknown
right (this.value = next) /value literal 1 unknown
comparison unknown: 0, coverage complete-within-inputs unknown: 2, coverage partial

Real application: Discord app.asar CLI output is identical: normalized JSON, 108,108,885 B both, 16.3 s vs 16.4 s. Output size is unchanged.

Tests:

  • New javascriptSemanticAnalysis.accessor_writes.test.ts: a write through a local setter leaves the returned object unknown, and a write to an ordinary property keeps the sibling value: 1 literal. The setter test fails on main; I ran it before the change.
  • 161 JavaScript/domain test files pass (2,975 tests), as do the export-shape and mutation-presence MCP boundary tests (21) and npm run check:fast.

Remaining

The issue also mentions the getter variant (const observed = state.update with get update() { this.value = 2; … }). A getter runs on reads, which this mutation collector does not model as effects. Handling it needs read-site effect tracking, so I've left it out of this PR rather than mark every read of an accessor-bearing object unknown.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/3831 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/3312-setter-write-effects` --- ### 📝 Commits (3) - [`9a8e239`](https://github.com/morluto/rea/commit/9a8e23915a9962b34b5007ecd53eabf5af3d96b3) fix(javascript): keep members unknown after a write through a local setter - [`6a6f44a`](https://github.com/morluto/rea/commit/6a6f44a0db0177106686442724e1bba5ae1e022b) fix(javascript): follow nested setters, skip deletes and cache setter keys - [`8bf89cf`](https://github.com/morluto/rea/commit/8bf89cf231a5c1a79ad9af68f92fa4b9dac4db26) fix(javascript): ignore setters replaced by a later data property ### 📊 Changes **2 files changed** (+194 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `src/domain/javascript/javascriptSemanticAnalysis.accessor_writes.test.ts` (+108 -0) 📝 `src/domain/javascript/javascriptSemanticMemberMutations.ts` (+86 -0) </details> ### 📄 Description Fixes #3312 (setter case; see Remaining for the getter variant) ## Root cause `collectSemanticMemberMutationsSteps` records `state.update = 2` as an ordinary write to path `["update"]`. When `update` is a **setter** of the binding's own object literal, the assignment runs the setter instead, and the setter may write any member of its receiver (`this.value = next`). Only `/update` was invalidated, so the sibling `value: 1` stayed a known literal. Static return shapes then showed `/value: 1`, and `compare-javascript-export-shapes` reported a no-op setter and a value-writing setter as complete and unchanged. ## Change In the mutation collector, a one-key write whose key names a `set` accessor on one of the binding's own object-literal initializers (projection `[]`) is recorded with an unknown key (`[null]`). The existing mutation lattice already turns that into `unknown` ("This property may have been mutated."). A computed setter key may match any written key, so it counts as matching. Writes to ordinary properties are unchanged and keep their sibling literals. ## Validation **The issue's public repro** (`analyze-javascript-application` on both fixtures, then `compare-javascript-export-shapes`): | | `main` | this PR | |---|---|---| | left (no-op setter) `/value` | `literal 1` | `unknown` | | right (`this.value = next`) `/value` | `literal 1` | `unknown` | | comparison | `unknown: 0`, coverage `complete-within-inputs` | `unknown: 2`, coverage `partial` | **Real application:** Discord `app.asar` CLI output is identical: normalized JSON, 108,108,885 B both, 16.3 s vs 16.4 s. Output size is unchanged. **Tests:** - New `javascriptSemanticAnalysis.accessor_writes.test.ts`: a write through a local setter leaves the returned object `unknown`, and a write to an ordinary property keeps the sibling `value: 1` literal. The setter test **fails on `main`**; I ran it before the change. - 161 JavaScript/domain test files pass (2,975 tests), as do the export-shape and mutation-presence MCP boundary tests (21) and `npm run check:fast`. ## Remaining The issue also mentions the getter variant (`const observed = state.update` with `get update() { this.value = 2; … }`). A getter runs on *reads*, which this mutation collector does not model as effects. Handling it needs read-site effect tracking, so I've left it out of this PR rather than mark every read of an accessor-bearing object unknown. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:10:33 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5933
No description provided.