Repository navigation
test(javascript): preserve member-alias fanout and loop regressions - #1414
akushonkamen wants to merge 4 commits into
Conversation
…ignment loops A loop that reassigns one reference through k members reached every injective member ordering because the cycle guard in markValue kept a per-path lifetime set. Expanding each (binding, effect, mutation, origin) state once bounds the traversal while every arrival still records its own effect, so no fact is added or widened. Fixes morluto#1401 Related morluto#1387
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
I reproduced a missing effect on head export function result() {
const left = { value: 1 };
const right = { value: 2 };
const source = { left, right };
const alias = flag ? source.left : source.right;
alias.value = 2;
return left.value;
}
The two arrivals reach the same binding/capture state with different paths. Recording both paths on I am maintaining the #1390 follow-up for #1401 and have retained its author's second commit and new write-depth regressions. The current follow-up passes these cases and the existing semantic suite; full CLI/MCP verification is being refreshed against current main. #1387 still has no confirmed common cause. |
…budget Collapsing every arrival of an alias state into its first expansion dropped genuinely affected child literals: two arrivals that differ only in path can select different children out of the same initializer (a conditional alias walking source.left versus source.right), so the skipped path never reached its child. Each distinct arrival path now expands, and only an alias state whose expansion budget is saturated skips further replay, which keeps reassignment loops polynomial.
|
Fixed in af1c093 — thank you for the precise reproducer. Root cause of the regression: the expansion dedupe keyed an alias state by Fix: the collector now expands every distinct arrival path — arrivals are already deduplicated by their recorded identity, which includes the path, so a novel arrival is a novel walk — and only bounds the replayed expansions per alias state ( Evidence on
One adjacent observation I left alone because it is pre-existing: with const inner = { q: 1, r: 2 };
const box = { p: inner };
const alias = box;
mutate(alias.p.q, alias.p.r);
return inner.r;the result is literal (This fix was prepared with AI assistance.) |
|
The original two-path reproducer is fixed in export function result() {
const c0 = { value: 0 }, c1 = { value: 1 }, c2 = { value: 2 };
const c3 = { value: 3 }, c4 = { value: 4 }, c5 = { value: 5 };
const c6 = { value: 6 }, c7 = { value: 7 }, c8 = { value: 8 };
const source = { m0:c0, m1:c1, m2:c2, m3:c3, m4:c4, m5:c5, m6:c6, m7:c7, m8:c8 };
const alias = flag===0 ? source.m0 : flag===1 ? source.m1 :
flag===2 ? source.m2 : flag===3 ? source.m3 : flag===4 ? source.m4 :
flag===5 ? source.m5 : flag===6 ? source.m6 : flag===7 ? source.m7 : source.m8;
alias.value = 99;
return c0.value;
}This reports literal #1390 has now merged as The adjacent |
|
Withdrawing in favor of #1390, which merged as Agreed on the nine-path reproducer: a fixed replay ceiling silently drops observed effects for any arrival beyond the cap, so it cannot establish sound bounding without explicitly marking omitted paths as uncertain. Exact-path propagation is the right shape, and it keeps the reassignment-loop bound polynomial at the same time. Also fair on Thanks for the precise reproducers throughout — the two-path conditional case and the nine-way fanout cleanly isolated the semantics. Keeping the branch on the fork for reference. (Prepared with AI assistance, consistent with the earlier comments on this PR.) |
|
TL;DR: af1c093 fixes 14 of the 17 wrong values I found on the first commit. That includes the two-argument call and the maintainer's case. Two kinds still go wrong: a short write loop and a nested loop. The merged #1390 gets all of these right. This PR closed, so this is for the record. Still wrong on af1c093const i0 = { v: 1 }; const i1 = { v: 1 }; const i2 = { v: 1 };
const seed = { m0: i0, m1: i1, m2: i2 };
let node = seed;
let k = 0;
while (k++ < 1) {
if (flag === 0) node = node.m0;
else if (flag === 1) node = node.m1;
else if (flag === 2) node = node.m2;
node.v = 2;
}
return i0.v;Real JS gives 2 when The nine-way case from the maintainer reproduces here too. Nine call arguments do the same thing. Results
The one wrong case on main is the Not run
Thanks, akushonkamen, for the quick fix and the clear write-up. The cause you named matched what I saw. All casesReal JS ran each body many times, with
The 14 cases fixed since the first commit:
The six facts the first commit kept are still kept. 03a960e keeps them too. TimingsThis is the #1401 loop with k members. Times are the analysis alone, median of 3. Load was about 9 to 10 from other jobs, so these are rough.
Every run said
Both give the same output on the chunk. Both say Next to #1390#1390 merged first and closed #1401. Its last head was 03a960e. On every case here, 03a960e gives no wrong value but the old Commands# each case: analyzeJavaScriptSemantics from the built dist/
node --max-old-space-size=3000 run.mjs <tree> file <case>.js
# loop timing, k = 6 to 12
node --max-old-space-size=3000 run.mjs <tree> loop <k>
# chunk, the two heads taking turns
node --max-old-space-size=5000 run.mjs <tree> module vendor-react-C4pS_tun.js
# changed tests
node node_modules/vitest/vitest.mjs run \
src/domain/javascript/javascriptSemanticAnalysis.member_mutations.test.ts \
src/domain/javascript/javascriptSemanticAnalysis.reference_lifetimes.test.tsEvery run used Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
|
Thanks, @akushonkamen, for the concrete alias-fanout reproducers that exposed how deduplication could hide real writes. Main now preserves those path-sensitive effects while bounding reassignment-loop expansion (main). |
Retain useful member-mutation regression coverage after the fixed-point propagation fix merged in #1390. Preserve the contributor's twelve-member reassignment-loop test and add compiled public CLI coverage for writes and escapes across eight, nine, and twelve conditional alias branches. Both the first and last affected children must remain unknown, while an unrelated sibling remains literal with complete projected return-shape coverage.
Review reproduced an accuracy defect in this PR's former eight-arrival cap: a 1,218-byte, source-owned JavaScript target with nine alias branches reported an affected child's return value as literal
1, with complete coverage. The same public CLI input on main4d95f2b2correctly reports unknown. Eight branches pass; nine and twelve fail on the capped implementation. Simply integrating main still retained the cap, so the follow-up removes that superseded runtime change and uses main's existing fixed-point owner unchanged. Overlapping module regressions already covered by main and the stronger CLI workflow are removed.The final diff adds tests only. It does not reintroduce a propagation cap, change default Evidence, or claim a new runtime performance improvement. Contributor commits are preserved through a normal merge and follow-up.
Validation:
--singleThreadedand the exact focused Vitest files serially under the local two-CPU and 2 GiB process-family budget; the focused lane peaked at 1.10 GiB, typechecking at 1.36 GiB. Test-discovery verification confirms all 704 test files are discovered exactly once, including the new boundary file.Refs #1401 and #1065. Prepared with AI assistance.