Repository navigation
fix(javascript): preserve effects through yielded array references - #1437
Conversation
There was a problem hiding this comment.
Reviewed 62bffde: yielded references retain their actual lexical owner and reuse existing iterable/copy semantics; member-expression loop heads preserve reference escapes. The original stale-literal CLI regression fails on unmodified main, and the corrected CLI/stdio MCP workflow covers 24 source variants while retaining unaffected literals. All 343 adjacent semantic tests, static checks, discovery and real Node 22/24 MCP probes pass. No schema or provider change. Final-head CI 38025036702 and Real JavaScript recovery 38025036687 completed successfully; all 20 checks passed and there are no unresolved review threads.
|
Independently rebuilt frozen main An additional 780-byte control target retains object-rest and array-rest exclusions, undefined defaults, and mutation provenance when the source variable is reassigned in the loop. Those controls match main. There is also a pre-existing precision gap, rather than a new regression: export function result() {
const shared = {x: 1}, other = {x: 2};
for (const {child: item = shared} of [{child: other}]) item.x = 3;
return shared.x;
}Both main and this head report unknown; actual source-owned Node execution returns The new acceptance child's explicitly selected environment also omits |
|
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: This merged while I was testing, so this is a post-merge check of Loop soundnessI ran 38 small loop cases on base
The untouched field stays The last row is safe, just careful. Base only got Regression, tests and speed
I reran the 59 cases from my #1390 review too. 55 give the same result and the same IR. The other 4 are for...of cases. Each went from a wrong Loop timings and the Hermes Desktop (MIT) chunk match base within noise. Numbers are in the fold. Not run
Thanks, N0zoM1z0, for such a quick fix. And thanks, akushonkamen, for finding the exact lines. The 9 shapes and the controlsThe 9 more for...of shapes:
The controls:
for...in, indexed SpeedMedian of 3 runs on Node 24, in ms:
Hermes Desktop (MIT) chunk, 3 runs each, analysis ms: base 1,521 / 1,577 / 1,520; Commands
Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
for...oflost the reference from its loop binding to a yielded array element, so a later member write left exported return shapes reporting a stale literal. Preserve yielded references through existing destructuring/copy handling and the iterable fallback boundary. Resolvevarand existing assignment targets in their actual lexical scope; treat yielded values stored in member-expression heads as escaped references.For example:
Before:
xwas reported as literal1. After:xis unknown andkeepremains literal7. Actual source-owned Node 22/24 execution returnsx: 2. The static analyzer does not pretend to execute the loop.Validation:
varand existing/destructured/member targets, copies/defaults/rest, update/delete/escape,for await...of, indexed loops, and unaffected sibling/read-only/empty/for-in/shadow controls. MCP text and structured results preserve the same Evidence; the session remains usable.npm run check:fastandnpm run verify:test-discoverypass.No tool inventory or public schema change. No native provider changed; real Hopper/Ghidra verification was not performed. No private application or Node 26 coverage is claimed.
Closes #1428.