[PR #775] [CLOSED] fix(semantics): isolate parameter expression environments #2233

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/775
Author: @rudycelekli
Created: 10/6/2026
Status: ❌ Closed

Base: main ← Head: fix/parameter-default-lexical-environment-20261006


📝 Commits (1)

  • 3a0405c fix(semantics): isolate parameter expression environments

📊 Changes

3 files changed (+178 additions, -4 deletions)

View changed files

➕ src/domain/javascriptSemanticAnalysis.parameter_environments.test.ts (+99 -0)
📝 src/domain/javascriptSemanticAnalysis.ts (+28 -4)
➕ tests/acceptance/applications/javascriptParameterEnvironmentCli.test.ts (+51 -0)

📄 Description

Summary

Keep default-parameter expressions and computed destructuring keys outside the function body var environment. The analyzer currently resolves a call in a default expression to a body-local declaration that is not visible there at runtime.

Functions with parameter expressions now have a separate body environment. Expression-free simple, destructured, and rest parameters retain their existing var environment. This is a lexical call-target correction; optional parameter values and cross-function argument values remain conservative.

Native reproduction

For function run(value = helper()) { function helper() { return 'INNER'; } return value; }, with an outer helper returning OUTER, Node returns OUTER. The built public analyzer previously linked the default call to the inner helper. It now links that call to the outer helper and retains the body call's inner target.

Native/public CLI controls cover a body declaration, body const, and arrow function. Checked regressions also cover body var, methods, default closures, computed/nested destructuring, parameter references, and expression-free var/parameter identity.

Verification

  • 217 focused semantic/graph and public CLI tests pass across 11 files.
  • npm run build:cached, npm run check, and npm run check:fast pass (125 lint warnings, zero errors).
  • Both this patch and the independent named function-expression fix combine cleanly: 231 tests across 14 files pass, with a native default-name/body-shadow control.
  • Signed DCO head: 3a0405ce88ebff8586c67e6024d5c63b14745b59.

No schema, provider, or packaged-artifact behavior changes are claimed. This does not claim complete ECMAScript binding or value analysis. Codex assisted on behalf of @rudycelekli with reproduction, implementation, tests, and an independent source review. Hosted CI runs separately.


🔄 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/775 **Author:** [@rudycelekli](https://github.com/rudycelekli) **Created:** 10/6/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/parameter-default-lexical-environment-20261006` --- ### 📝 Commits (1) - [`3a0405c`](https://github.com/morluto/rea/commit/3a0405ce88ebff8586c67e6024d5c63b14745b59) fix(semantics): isolate parameter expression environments ### 📊 Changes **3 files changed** (+178 additions, -4 deletions) <details> <summary>View changed files</summary> ➕ `src/domain/javascriptSemanticAnalysis.parameter_environments.test.ts` (+99 -0) 📝 `src/domain/javascriptSemanticAnalysis.ts` (+28 -4) ➕ `tests/acceptance/applications/javascriptParameterEnvironmentCli.test.ts` (+51 -0) </details> ### 📄 Description ## Summary Keep default-parameter expressions and computed destructuring keys outside the function body var environment. The analyzer currently resolves a call in a default expression to a body-local declaration that is not visible there at runtime. Functions with parameter expressions now have a separate body environment. Expression-free simple, destructured, and rest parameters retain their existing var environment. This is a lexical call-target correction; optional parameter values and cross-function argument values remain conservative. ## Native reproduction For `function run(value = helper()) { function helper() { return 'INNER'; } return value; }`, with an outer helper returning `OUTER`, Node returns `OUTER`. The built public analyzer previously linked the default call to the inner helper. It now links that call to the outer helper and retains the body call's inner target. Native/public CLI controls cover a body declaration, body const, and arrow function. Checked regressions also cover body var, methods, default closures, computed/nested destructuring, parameter references, and expression-free var/parameter identity. ## Verification - 217 focused semantic/graph and public CLI tests pass across 11 files. - `npm run build:cached`, `npm run check`, and `npm run check:fast` pass (125 lint warnings, zero errors). - Both this patch and the independent named function-expression fix combine cleanly: 231 tests across 14 files pass, with a native default-name/body-shadow control. - Signed DCO head: `3a0405ce88ebff8586c67e6024d5c63b14745b59`. No schema, provider, or packaged-artifact behavior changes are claimed. This does not claim complete ECMAScript binding or value analysis. Codex assisted on behalf of @rudycelekli with reproduction, implementation, tests, and an independent source review. Hosted CI runs separately. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-16 21:16:01 +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#2233
No description provided.