Skip to content

fix(javascript): honor computed keys when naming callables, exports, requests and options - #536

Merged
morluto merged 1 commit into
mainfrom
cleanup/semantic-computed-keys
Oct 5, 2026
Merged

morluto merged 1 commit into
mainfrom
cleanup/semantic-computed-keys

Conversation

@morluto

@morluto morluto commented Oct 5, 2026

Copy link
Copy Markdown
Owner

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-05T07:51:51.337265Z 19d3573 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19d3573419

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// `exports[key]`/`module.exports[key]` assign an export whose name is not
// knowable. Report the wildcard rather than the variable name, and never
// collapse it into `default`, which would claim a real default export.
if (key === null) return "*";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Check the export receiver before accepting a dynamic key

For any ordinary dynamic assignment such as cache[key] = value, key is null and this early return reports a wildcard CommonJS export without first verifying that the receiver is exports or module.exports. collectCommonJsExport therefore adds a fabricated module link, and downstream moduleFormat can misclassify otherwise unrelated source as CommonJS; restrict the wildcard result to recognized CommonJS export receivers.

AGENTS.md reference: AGENTS.md:L9-L9

Useful? React with 👍 / 👎.

@morluto
morluto merged commit 4c8dc39 into main Oct 5, 2026
18 checks passed
@morluto
morluto deleted the cleanup/semantic-computed-keys branch October 5, 2026 07:52
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
@morluto morluto added bug Something isn't working area: domain Domain logic, errors, and pure functions labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant