Repository navigation
fix(javascript): resolve exported callables through lexical bindings - #1351
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
TL;DR: I checked this on Linux, and it fixes the cases it targets. On 6.2.0 and main, a reassigned function export keeps its old return shape. So a real change between two versions reads as "no change". On this branch the same comparison comes back partial. A plain export that really changed is still caught. The PR's The full suite passes too, after For a before and after, each build analyzed v1 and v2 of one
Here is P1's v1. Its v2 returns function current() { return { count: 0 }; }
current = () => ({ count: 1 });
export { current as default };P3's v1 is On 6.2.0 and main, P1 and P3 report the One more thing, and it isn't from this PR. Over stdio MCP, a second partial comparison in one session fails with Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
|
Reviewed 0e59898. No blocking correctness issue found. Retaining the lexical binding for each module link fixes the important distinction between callable display names and binding identity. Deferring writes until declarations are collected addresses hoisting/shadowing, and the parameter-expression/body environment plus computed method-key handling is supported by the supplied runtime-oracle cases. The public CLI/MCP tests cover reassignment uncertainty, private-name collisions, nested CommonJS bindings and stable export controls. CI is green at this head. I would merge this before #1292, then rebase/retest the latter: both change semantic state/collection and their combined behavior needs the exported-binding and reference-lifetime regressions, even if Git currently reports each as conflict-free. Review scope: changed collection/projection/return-binding code and supplied producer-backed tests. This is not a claim that I independently ran every acceptance case or optional real-provider lane. |
|
TL;DR: Thanks for the review and the merge. I ran the combined check you asked for on main, with both PRs in. It's clean: the full suite passes, and this PR's cases still come out the same. The details are on #1292. 🤖 Generated with Claude Code (Opus 5.5) 🦊 |
…orluto#1351) * fix(javascript): resolve exported callables through lexical bindings * fix(javascript): preserve export scope and hoisted writes * test(javascript): consolidate export binding assertions * fix(javascript): account for skipped initializers and loop binding writes * fix(javascript): preserve parameters copied into body variables
Summary
Fix exported callable resolution so reassigned bindings cannot retain stale return shapes and private function names cannot attach to unrelated exports. Also resolve nested CommonJS exports through their actual lexical binding and account for writes before hoisted declarations. Reported directly during a source audit; no issue number was supplied.
Problem and expected behavior
Two versions that reassign an exported function to return
count: 1andcount: 2incorrectly compared as zero changes and zero unknowns. Callable IDs and display names bypassed binding checks. Root-scope lookup also associated nested CommonJS exports with unrelated outer bindings, and writes collected before declarations could be dropped or assigned to the wrong scope.Uncertain, multiply assigned exports must report the existing unavailable/unknown result. Stable function exports and aliases must still compare their actual return shapes.
Change and scope
Contract and boundary impact
Evidence and regression coverage
count: 1versuscount: 2behavior.left.status = right.status = "unavailable",summary.unknown = 1, and partial coverage. Stable callable comparisons retain the/countchange.Validation performed
npm run test:local -- src/domain/javascript/*.test.ts: 557 passed across 36 files.npm run test:focused -- tests/acceptance/applications/exportedFunctionBindingsCli.test.ts: all 29 compiled CLI/MCP regression cases passed.npm run check: passed, including typecheck, lint, formatting, unused-code, metadata, and module-boundary checks.npm run check:ci: passed, including duplication and TODO checks. Shared assertions reduce local duplicated lines to 2.49% under the 2.5% gate.npm run verify:test-discovery: all 696 local test files discovered exactly once.git diff --check: passed.Compatibility and review
No schema migration or execution authority change. Real Hopper/Ghidra and browser verification was not performed because this changes static JavaScript binding resolution only. Full deterministic coverage remains with CI as directed by the repository's focused-check workflow.