[PR #536] [MERGED] fix(javascript): honor computed keys when naming callables, exports, requests and options #2057

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/536
Author: @morluto
Created: 10/5/2026
Status: ✅ Merged
Merged: 10/5/2026
Merged by: @morluto

Base: main ← Head: cleanup/semantic-computed-keys


📝 Commits (1)

  • 19d3573 fix(javascript): honor computed keys when naming callables, exports, requests and options

📊 Changes

6 files changed (+84 additions, -9 deletions)

View changed files

📝 src/domain/javascriptSemanticAnalysis.runtime_boundaries.test.ts (+18 -0)
📝 src/domain/javascriptSemanticAnalysis.structure.test.ts (+22 -0)
📝 src/domain/javascriptSemanticChildProcesses.ts (+3 -1)
📝 src/domain/javascriptSemanticDataEffects.ts (+3 -1)
📝 src/domain/javascriptSemanticProjection.ts (+25 -6)
📝 src/domain/javascriptStaticAnalysisHelpers.ts (+13 -1)

📄 Description

Generalizes the fix from #507 (computed destructuring keys) to the four sibling readers that still resolved a property name straight off the key node without consulting computed. Each one reports an invented name — a variable name presented as a fact about the program.

  • commonJsExportName: exports[key] = addon yielded exportedName: "key", and module.exports[key] = addon yielded default, claiming a real default export. Now returns null for a non-committing key and reports the wildcard * — the assignment is observed, its name is not invented, and it is no longer collapsed into default.
  • callableName: {[key]() {}} and class A { [key]() {} } were named key; they now use the existing [computed@<offset>] form the module-table reader already uses.
  • requestFields: fetch(url, {[key]: 1}) reported a request field named key.
  • objectProperty (child processes): spawn(cmd, {[env]: vars}) was read as a literal env option and set environmentSupplied: true.
  • calleeNameAt: target[method]() produced target.method, fabricating a runtime call shape.

Root cause is one shared defect rather than five: semanticStaticPropertyName(key, computed) already existed for exactly this, but only 5 of ~10 call sites used it. Rather than patch each reader again, I added a local memberKey helper in the projection module (distinguishing "no name" from "empty name") and routed the CJS export path through it.

Tests: added dynamic-key cases to the structure and runtime-boundaries suites. Full suite green (1918 passed); the only 2 failures were a stale generated docs/product-catalog.json digest left by the concurrent #535 schema work, which resolves after npm ci + mcp-catalog:generate and is unrelated to this change.


🔄 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/536 **Author:** [@morluto](https://github.com/morluto) **Created:** 10/5/2026 **Status:** ✅ Merged **Merged:** 10/5/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `cleanup/semantic-computed-keys` --- ### 📝 Commits (1) - [`19d3573`](https://github.com/morluto/rea/commit/19d3573419e4b9839122f474bc78df7f4cd658c0) fix(javascript): honor computed keys when naming callables, exports, requests and options ### 📊 Changes **6 files changed** (+84 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/javascriptSemanticAnalysis.runtime_boundaries.test.ts` (+18 -0) 📝 `src/domain/javascriptSemanticAnalysis.structure.test.ts` (+22 -0) 📝 `src/domain/javascriptSemanticChildProcesses.ts` (+3 -1) 📝 `src/domain/javascriptSemanticDataEffects.ts` (+3 -1) 📝 `src/domain/javascriptSemanticProjection.ts` (+25 -6) 📝 `src/domain/javascriptStaticAnalysisHelpers.ts` (+13 -1) </details> ### 📄 Description Generalizes the fix from #507 (computed destructuring keys) to the four sibling readers that still resolved a property name straight off the key node without consulting `computed`. Each one reports an *invented* name — a variable name presented as a fact about the program. - `commonJsExportName`: `exports[key] = addon` yielded `exportedName: "key"`, and `module.exports[key] = addon` yielded `default`, claiming a real default export. Now returns `null` for a non-committing key and reports the wildcard `*` — the assignment is observed, its name is not invented, and it is no longer collapsed into `default`. - `callableName`: `{[key]() {}}` and `class A { [key]() {} }` were named `key`; they now use the existing `[computed@<offset>]` form the module-table reader already uses. - `requestFields`: `fetch(url, {[key]: 1})` reported a request field named `key`. - `objectProperty` (child processes): `spawn(cmd, {[env]: vars})` was read as a literal `env` option and set `environmentSupplied: true`. - `calleeNameAt`: `target[method]()` produced `target.method`, fabricating a runtime call shape. Root cause is one shared defect rather than five: `semanticStaticPropertyName(key, computed)` already existed for exactly this, but only 5 of ~10 call sites used it. Rather than patch each reader again, I added a local `memberKey` helper in the projection module (distinguishing "no name" from "empty name") and routed the CJS export path through it. Tests: added dynamic-key cases to the structure and runtime-boundaries suites. Full suite green (1918 passed); the only 2 failures were a stale generated `docs/product-catalog.json` digest left by the concurrent #535 schema work, which resolves after `npm ci` + `mcp-catalog:generate` and is unrelated to this change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-16 21: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#2057
No description provided.