[PR #4465] [MERGED] fix(domain): classify TypeScript parameter properties as declarations rather than identifier reads #6258

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

📋 Pull Request Information

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

Base: main ← Head: fix/issue-4371-ts-parameter-property-references


📝 Commits (2)

  • b0a2f7a fix(domain): classify TypeScript parameter properties as declarations rather than identifier reads
  • 309e2a2 test(domain): assert constructor body parameter property reads survive

📊 Changes

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

View changed files

📝 src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts (+38 -0)
📝 src/domain/javascript/javascriptSemanticProjection.ts (+5 -0)

📄 Description

Summary

Fixes #4371.

When semantic reference collection processes a TypeScript class constructor with parameter properties (e.g. constructor(public x: number) {} or constructor(public x = 1) {}), the declaration token x was erroneously emitted as a source identifier read reference (role: "read"). This occurred because isDeclarationIdentifier and isPatternOwnerDeclaration did not recognize TSParameterProperty, and patternContains lacked support for unwrapping TSParameterProperty.parameter.

This PR updates src/domain/javascript/javascriptSemanticProjection.ts to recognize TSParameterProperty across these helpers, ensuring parameter properties are treated as definitions while preserving actual reads in initializers and method bodies.

Problem and expected behavior

  • Observed behavior: A parameter property declaration in class C { constructor(public x: number) {} } or class C { constructor(public x = 1) {} } resulted in x:read in ir.references.
  • Expected behavior: Parameter property declarations should remain definitions without producing false source identifier reads, matching ordinary parameters (constructor(x: number) {}). Actual reads in initializers (e.g. constructor(public x = seed) {}) and bodies (e.g. console.log(y)) must be preserved.

Change and scope

  • Added t.isTSParameterProperty(node) to isPatternOwnerDeclaration.
  • Added t.isTSParameterProperty(parent) && patternContains(parent.parameter, node) to isDeclarationIdentifier.
  • Added t.isTSParameterProperty(pattern) && patternContains(pattern.parameter, target) to patternContains, aligning it with patternNames.
  • Added unit tests in src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts, verifying that parameter property declarations produce no spurious read references while constructor body parameter reads and default initializer reads survive.

Contract and boundary impact

  • Semantic owner and earliest changed stage: JavaScript semantic reference classification (javascriptSemanticProjection.ts)

  • Contribution scope fit and linked maintainer decision: Not applicable (pure domain bug fix)

  • CLI and MCP/tool-catalog contract: none

  • Provider, bridge, target-format, or platform compatibility: all platforms

  • Evidence, artifact, provenance, or reconstruction contract: none

  • Target selection, authority, upstream behavior, and cleanup details (if applicable): none

  • Generated metadata impact: none

  • 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: src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts
  • Base reproduction or other evidence: Reproducer in issue #4371 reproduced with exit 0 on base revision and verified resolved with 0 spurious reads.
  • User-visible CLI/MCP output (if applicable): none
  • Remaining proof gaps: none

Validation performed

  • npm run test:local -- src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts — 73 passed (100%)
  • npm run test:local -- src/domain/javascript/javascriptSemanticAnalysis.dataflow.test.ts src/domain/javascript/javascriptSemanticAnalysis.reference_lifetimes.test.ts — 179 passed (100%)
  • npx turbo run typecheck lint --force — 2 tasks successful (0 errors)
  • node scripts/verify-module-boundaries.mjs — Checked 1979 source files (0 errors)
  • node scripts/verify/architecture-guards.mjs — Checked 1455 source files (0 errors)
  • npm run format:check — All 3765 files formatted properly

Compatibility, safety, and release

  • Breaking changes or migration steps: None
  • Real Hopper/Ghidra, browser, or OS coverage: Platform-independent domain logic
  • Package or release metadata impact: None
  • Security, privacy, process, or containment review: Pure AST classification change; no security/containment impact

Author readiness

Human owner: @kevinjosh10

  • 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.

🔄 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/4465 **Author:** [@kevinjosh10](https://github.com/kevinjosh10) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/issue-4371-ts-parameter-property-references` --- ### 📝 Commits (2) - [`b0a2f7a`](https://github.com/morluto/rea/commit/b0a2f7a94fec76fbb719c182586b19557100c286) fix(domain): classify TypeScript parameter properties as declarations rather than identifier reads - [`309e2a2`](https://github.com/morluto/rea/commit/309e2a28ea6427794cbcb814e0e493f7bb3b4d38) test(domain): assert constructor body parameter property reads survive ### 📊 Changes **2 files changed** (+43 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts` (+38 -0) 📝 `src/domain/javascript/javascriptSemanticProjection.ts` (+5 -0) </details> ### 📄 Description ## Summary Fixes #4371. When semantic reference collection processes a TypeScript class constructor with parameter properties (e.g. `constructor(public x: number) {}` or `constructor(public x = 1) {}`), the declaration token `x` was erroneously emitted as a source identifier read reference (`role: "read"`). This occurred because `isDeclarationIdentifier` and `isPatternOwnerDeclaration` did not recognize `TSParameterProperty`, and `patternContains` lacked support for unwrapping `TSParameterProperty.parameter`. This PR updates `src/domain/javascript/javascriptSemanticProjection.ts` to recognize `TSParameterProperty` across these helpers, ensuring parameter properties are treated as definitions while preserving actual reads in initializers and method bodies. ## Problem and expected behavior - **Observed behavior**: A parameter property declaration in `class C { constructor(public x: number) {} }` or `class C { constructor(public x = 1) {} }` resulted in `x:read` in `ir.references`. - **Expected behavior**: Parameter property declarations should remain definitions without producing false source identifier reads, matching ordinary parameters (`constructor(x: number) {}`). Actual reads in initializers (e.g. `constructor(public x = seed) {}`) and bodies (e.g. `console.log(y)`) must be preserved. ## Change and scope - Added `t.isTSParameterProperty(node)` to `isPatternOwnerDeclaration`. - Added `t.isTSParameterProperty(parent) && patternContains(parent.parameter, node)` to `isDeclarationIdentifier`. - Added `t.isTSParameterProperty(pattern) && patternContains(pattern.parameter, target)` to `patternContains`, aligning it with `patternNames`. - Added unit tests in `src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts`, verifying that parameter property declarations produce no spurious read references while constructor body parameter reads and default initializer reads survive. ## Contract and boundary impact - Semantic owner and earliest changed stage: JavaScript semantic reference classification (`javascriptSemanticProjection.ts`) - Contribution scope fit and linked maintainer decision: Not applicable (pure domain bug fix) - CLI and MCP/tool-catalog contract: none - Provider, bridge, target-format, or platform compatibility: all platforms - Evidence, artifact, provenance, or reconstruction contract: none - Target selection, authority, upstream behavior, and cleanup details (if applicable): none - Generated metadata impact: none - [ ] 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: `src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts` - Base reproduction or other evidence: Reproducer in issue #4371 reproduced with exit 0 on base revision and verified resolved with 0 spurious reads. - User-visible CLI/MCP output (if applicable): none - Remaining proof gaps: none ## Validation performed - `npm run test:local -- src/domain/javascript/javascriptSemanticAnalysis.structure.test.ts` — 73 passed (100%) - `npm run test:local -- src/domain/javascript/javascriptSemanticAnalysis.dataflow.test.ts src/domain/javascript/javascriptSemanticAnalysis.reference_lifetimes.test.ts` — 179 passed (100%) - `npx turbo run typecheck lint --force` — 2 tasks successful (0 errors) - `node scripts/verify-module-boundaries.mjs` — Checked 1979 source files (0 errors) - `node scripts/verify/architecture-guards.mjs` — Checked 1455 source files (0 errors) - `npm run format:check` — All 3765 files formatted properly ## Compatibility, safety, and release - Breaking changes or migration steps: None - Real Hopper/Ghidra, browser, or OS coverage: Platform-independent domain logic - Package or release metadata impact: None - Security, privacy, process, or containment review: Pure AST classification change; no security/containment impact ## Author readiness Human owner: @kevinjosh10 - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] 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:05 +00:00
bsakaguchi changed title from [PR #4465] [MERGED] fix(domain): classify TypeScript parameter properties as declarations rather than identifier reads to [PR #4465] fix(domain): classify TypeScript parameter properties as declarations rather than identifier reads 2026-11-03 13:32:27 +00:00
bsakaguchi changed title from [PR #4465] fix(domain): classify TypeScript parameter properties as declarations rather than identifier reads to [PR #4465] [MERGED] fix(domain): classify TypeScript parameter properties as declarations rather than identifier reads 2026-11-03 14:34:11 +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#6258
No description provided.