[PR #1657] [CLOSED] fix(reference): ignore lexically shadowed require lookups #4730

Closed
opened 2026-10-31 00:54:26 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/reference-shadowed-require-20261010


📝 Commits (4)

  • 35a963e fix(reference): ignore lexically shadowed require lookups
  • 083e15b test(reference): use current resource-owned importer fixture
  • 092ee7e test(reference): preserve existing recovery diagnostics
  • 8de54e0 fix(reference): retain owned parser metadata type

📊 Changes

2 files changed (+163 additions, -9 deletions)

View changed files

📝 src/domain/referenceSourceImportParsing.ts (+43 -9)
➕ tests/boundary/filesystem/referenceSourceShadowedRequire.test.ts (+120 -0)

📄 Description

Reference source import currently treats locally bound require calls as CommonJS dependencies. For example, function load(require) { return require("./throwing.cjs"); } creates a dependency edge even when the caller supplies its own loader. The JavaScript semantic analyzer already understands lexical bindings; this change reuses it to accept only unbound global require references, including the supported resolve and main forms.

The regression executes owned Node fixtures and imports them through the production resource-owned source importer. It covers parameters, destructuring, hoisted declarations, catch bindings, dynamic lookup, genuine CommonJS controls, and static/dynamic ESM controls. Existing parser diagnostics are preserved. This addresses source-import relationships; the earlier semantic-analyzer fix in #509 is reused.

Validation on application commit 8de54e086308a2386a0fd0b898d7e2764e36ca4c:

  • The official focused regression fails on the unchanged parser at the intended relationship assertion; an independent structured classifier confirms that failure.
  • Four focused boundary files: 16 tests passed.
  • npm run verify:test-discovery, npm run check, and npm run build:cached passed with locked dependencies, Node 24.18.0 and npm 11.16.0.
  • Fork validation run explicitly checked out the application SHA and verified its source, test, and lockfile hashes. Its workflow-only child is separate from this PR.

The tested base is 4999e4be; main subsequently advanced to 26038912 without changes to either PR file. The shared semantic projection change only removes the bare CommonJS exports alias and does not alter reference collection. Full-suite and native-provider verification are not claimed. Prepared with AI assistance.


🔄 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/1657 **Author:** [@rudycelekli](https://github.com/rudycelekli) **Created:** 10/11/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/reference-shadowed-require-20261010` --- ### 📝 Commits (4) - [`35a963e`](https://github.com/morluto/rea/commit/35a963ee4b784f984d223b9cdb5804b19574c116) fix(reference): ignore lexically shadowed require lookups - [`083e15b`](https://github.com/morluto/rea/commit/083e15b7bc68f58d390aa2ef11f6bbe8ba408aea) test(reference): use current resource-owned importer fixture - [`092ee7e`](https://github.com/morluto/rea/commit/092ee7ef26be6ab9fe5e2e5a0df8e8c49f9e2490) test(reference): preserve existing recovery diagnostics - [`8de54e0`](https://github.com/morluto/rea/commit/8de54e086308a2386a0fd0b898d7e2764e36ca4c) fix(reference): retain owned parser metadata type ### 📊 Changes **2 files changed** (+163 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/referenceSourceImportParsing.ts` (+43 -9) ➕ `tests/boundary/filesystem/referenceSourceShadowedRequire.test.ts` (+120 -0) </details> ### 📄 Description Reference source import currently treats locally bound `require` calls as CommonJS dependencies. For example, `function load(require) { return require("./throwing.cjs"); }` creates a dependency edge even when the caller supplies its own loader. The JavaScript semantic analyzer already understands lexical bindings; this change reuses it to accept only unbound global `require` references, including the supported `resolve` and `main` forms. The regression executes owned Node fixtures and imports them through the production resource-owned source importer. It covers parameters, destructuring, hoisted declarations, catch bindings, dynamic lookup, genuine CommonJS controls, and static/dynamic ESM controls. Existing parser diagnostics are preserved. This addresses source-import relationships; the earlier semantic-analyzer fix in #509 is reused. Validation on application commit `8de54e086308a2386a0fd0b898d7e2764e36ca4c`: - The official focused regression fails on the unchanged parser at the intended relationship assertion; an independent structured classifier confirms that failure. - Four focused boundary files: 16 tests passed. - `npm run verify:test-discovery`, `npm run check`, and `npm run build:cached` passed with locked dependencies, Node 24.18.0 and npm 11.16.0. - [Fork validation run](https://github.com/rudycelekli/rea/actions/runs/38096039958) explicitly checked out the application SHA and verified its source, test, and lockfile hashes. Its workflow-only child is separate from this PR. The tested base is `4999e4be`; main subsequently advanced to `26038912` without changes to either PR file. The shared semantic projection change only removes the bare CommonJS exports alias and does not alter reference collection. Full-suite and native-provider verification are not claimed. Prepared with AI assistance. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:54:26 +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#4730
No description provided.