[PR #4669] [CLOSED] fix(javascript): invalidate array element receivers on setter writes #6352

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4669
Author: @akram1089
Created: 10/17/2026
Status: ❌ Closed

Base: main ← Head: fix/4630-array-setter-return-literals


📝 Commits (2)

  • 0ab62d4 fix(javascript): invalidate array element receivers on setter writes
  • 4eee739 test(javascript): cover array element setter return variants and controls

📊 Changes

2 files changed (+103 additions, -11 deletions)

View changed files

📝 src/domain/javascript/javascriptSemanticAnalysis.accessor_writes.test.ts (+67 -0)
📝 src/domain/javascript/javascriptSemanticMemberMutations.ts (+36 -11)

📄 Description

Summary

Fixes #4630.

When an assignment invokes an own setter on an object inside an array (either directly arr[0].update = 2 or nested state.list[0].update = 2), static analysis previously retained exact stale sibling literals for earlier members (e.g. value: 1) instead of marking the mutated receiver unknown. This PR extends receiver resolution to traverse array expressions so setter writes invalidate the element's property slots while preserving exact literals for ordinary data properties and no-write controls.

Problem and expected behavior

  • Prior behavior: localSetterReceiver traversed object-literal properties and immediately broke if any segment encountered an ArrayExpression. Consequently, it returned undefined, leaving path as the literal setter key only. Sibling properties on that element were not invalidated and published stale exact values.
  • Expected behavior: An assignment targeting a setter on an array element must invalidate the element's slots, returning unknown for earlier sibling properties unless the post-write value can be justified. Ordinary property writes without accessors and no-write controls must remain exact.

Change and scope

  • src/domain/javascript/javascriptSemanticMemberMutations.ts: in localSetterReceiver, added an else if (t.isArrayExpression(object)) branch that converts the segment to a numeric index via semanticArrayIndex. It validates array bounds and stops if any preceding element is a spread element.
  • src/domain/javascript/javascriptSemanticAnalysis.accessor_writes.test.ts: added test cases for nested array-element setter writes, direct array-element setter writes, and ordinary data-property writes on array elements.

Contract and boundary impact

  • Semantic owner and earliest changed stage: JavaScript semantic member mutation collection (src/domain/javascript/javascriptSemanticMemberMutations.ts)
  • Contribution scope fit and linked maintainer decision: not applicable (bug fix within existing static analysis boundaries)
  • CLI and MCP/tool-catalog contract: none (preserves existing schema and uncertainty representation)
  • Provider, bridge, target-format, or platform compatibility: none
  • Evidence, artifact, provenance, or reconstruction contract: preserves conservative unknown representation
  • Target selection, authority, upstream behavior, and cleanup details: not applicable
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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:
    • keeps array element members unknown after a write through an element setter
    • keeps direct array element members unknown after a write through an element setter
    • keeps sibling literals when array element property written is an ordinary data property
  • Base reproduction: verified reproduction in Vitest where the two setter cases failed with status: "object" instead of status: "unknown", while the ordinary property control passed.
  • User-visible CLI/MCP output: not applicable
  • Remaining proof gaps: none

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

  • npm run test:local -- src/domain/javascript/javascriptSemanticAnalysis.accessor_writes.test.ts — passed (8 passed)
  • npm run test:local -- src/domain/javascript/javascriptSemanticAnalysis.accessor_writes.test.ts src/domain/javascript/javascriptSemanticAnalysis.member_mutations.test.ts src/domain/javascript/javascriptSemanticAnalysis.member_depth.test.ts src/domain/javascript/javascriptSemanticMutationInitializers.test.ts — passed (228 passed)
  • npm run check:fast — passed (turbo typecheck and lint clean)

Compatibility, safety, and release

  • Breaking changes or migration steps: none
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: pure static AST analysis; no execution of target code

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.

🔄 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/4669 **Author:** [@akram1089](https://github.com/akram1089) **Created:** 10/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/4630-array-setter-return-literals` --- ### 📝 Commits (2) - [`0ab62d4`](https://github.com/morluto/rea/commit/0ab62d43554a976f1307485a22b7957d03801f6a) fix(javascript): invalidate array element receivers on setter writes - [`4eee739`](https://github.com/morluto/rea/commit/4eee73983a77cc4024a0e6fdc69424d6d8bd479a) test(javascript): cover array element setter return variants and controls ### 📊 Changes **2 files changed** (+103 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/javascript/javascriptSemanticAnalysis.accessor_writes.test.ts` (+67 -0) 📝 `src/domain/javascript/javascriptSemanticMemberMutations.ts` (+36 -11) </details> ### 📄 Description ## Summary Fixes #4630. When an assignment invokes an own setter on an object inside an array (either directly `arr[0].update = 2` or nested `state.list[0].update = 2`), static analysis previously retained exact stale sibling literals for earlier members (e.g. `value: 1`) instead of marking the mutated receiver unknown. This PR extends receiver resolution to traverse array expressions so setter writes invalidate the element's property slots while preserving exact literals for ordinary data properties and no-write controls. ## Problem and expected behavior - **Prior behavior**: `localSetterReceiver` traversed object-literal properties and immediately broke if any segment encountered an `ArrayExpression`. Consequently, it returned `undefined`, leaving `path` as the literal setter key only. Sibling properties on that element were not invalidated and published stale exact values. - **Expected behavior**: An assignment targeting a setter on an array element must invalidate the element's slots, returning `unknown` for earlier sibling properties unless the post-write value can be justified. Ordinary property writes without accessors and no-write controls must remain exact. ## Change and scope - `src/domain/javascript/javascriptSemanticMemberMutations.ts`: in `localSetterReceiver`, added an `else if (t.isArrayExpression(object))` branch that converts the segment to a numeric index via `semanticArrayIndex`. It validates array bounds and stops if any preceding element is a spread element. - `src/domain/javascript/javascriptSemanticAnalysis.accessor_writes.test.ts`: added test cases for nested array-element setter writes, direct array-element setter writes, and ordinary data-property writes on array elements. ## Contract and boundary impact - Semantic owner and earliest changed stage: JavaScript semantic member mutation collection (`src/domain/javascript/javascriptSemanticMemberMutations.ts`) - Contribution scope fit and linked maintainer decision: not applicable (bug fix within existing static analysis boundaries) - CLI and MCP/tool-catalog contract: none (preserves existing schema and uncertainty representation) - Provider, bridge, target-format, or platform compatibility: none - Evidence, artifact, provenance, or reconstruction contract: preserves conservative unknown representation - Target selection, authority, upstream behavior, and cleanup details: not applicable - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact: none Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [ ] 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. - [x] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: - `keeps array element members unknown after a write through an element setter` - `keeps direct array element members unknown after a write through an element setter` - `keeps sibling literals when array element property written is an ordinary data property` - Base reproduction: verified reproduction in Vitest where the two setter cases failed with `status: "object"` instead of `status: "unknown"`, while the ordinary property control passed. - User-visible CLI/MCP output: not applicable - Remaining proof gaps: none For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:local -- src/domain/javascript/javascriptSemanticAnalysis.accessor_writes.test.ts` — passed (8 passed) - `npm run test:local -- src/domain/javascript/javascriptSemanticAnalysis.accessor_writes.test.ts src/domain/javascript/javascriptSemanticAnalysis.member_mutations.test.ts src/domain/javascript/javascriptSemanticAnalysis.member_depth.test.ts src/domain/javascript/javascriptSemanticMutationInitializers.test.ts` — passed (228 passed) - `npm run check:fast` — passed (turbo typecheck and lint clean) ## Compatibility, safety, and release - Breaking changes or migration steps: none - Real Hopper/Ghidra, browser, or OS coverage: not applicable - Package or release metadata impact: none - Security, privacy, process, or containment review: pure static AST analysis; no execution of target code ## Before merge <!-- Draft PRs may leave pending items unchecked. Resolve material scope and authority questions before integration. --> - [ ] 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:13:48 +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#6352
No description provided.