Repository navigation
fix(javascript): retain returned-reference mutation uncertainty - #1471
Conversation
There was a problem hiding this comment.
Final-head review complete for 8414ee4. All CI lanes, including real JavaScript recovery and all native package baselines, are green. The 34-case compiled CLI/stdio MCP regression and Node 22/24 runtime checks preserve scalar copies and unrelated fields while removing stale returned-reference facts. Conservative read-only escape uncertainty is documented. No remaining blocking findings.
|
TL;DR: #1471 fixes 11 of the 13 call forms that #1468 left wrong, and 24 of 28 new ones. Its tests and Head
The 2 left in the #1449 set are the cross-module rows. Real JS gives 2 there only when Still wrong: gettersconst shared = { x: 1 };
const box = { get v() { return shared; } };
box.v.x = 2;
return shared.x; // real 2; main and #1471 say literal 1, coverage completeA class getter, a static getter and a getter copied into a local first fail the same way. A getter read is not a call, so the new hook never sees it. Slower: many methods on one objectAn object with N methods that all return it, then N calls like
Each doubling costs about 4 times as much at the top. I reran N = 2,000 once and got 0.84 s and 7.9 s. The box was busy for all of these runs. So read them as rough, but the gap is far larger than the noise. Plain PrecisionRead-only calls now give Not run
Thanks, N0zoM1z0, for taking on the method, async and generator forms. The 34-variant test made the cases easy to match. The 64 cases from #1449Re-run of the 64 cases from #1449 on #1471Real JS returns 2 for every row in this table. (The last row needs
Result: #1471 fixes 11 of the 13 rows that #1468 left wrong. All 11 return a reference. They are methods, a class method, a call chain, a conditional return, Controls: 19 forms where 1 is right. On main, 17 keep
Those six moves are safe, but less precise. The PR body says read-only calls may become Agreement: the CLI gives the same answer on Node 22.23.1, 24.18.0 and 26.11.1 for all 64 cases. The MCP server ( Full matrix (64 cases, #1471)Each case is
Commands
Tests and speed detailTestsHead is
On base, the test fails at the first variant, I also ran a copy of the test that keeps going after a failure, on Node 24 only. On base, 27 of the 34 variants fail with the same stale The base lint run has 498 warnings. Head adds 4, all in the new file The PR says six adjacent suites pass 353 tests. It does not name them. I did not reproduce that exact set. All 38 files in SpeedNode 24.18.0. Each cell is the median of 3 runs of the analysis step, in milliseconds. The base tree is
Set 1 started at load 5.5 to 6.7. Set 2 started at load 9.3 to 10.4. Load average counts the processes that are running or waiting. This CPU has 24 threads. Other tests were running on the box. The gap between trees changes sign from set 1 to set 2: for On the Hermes chunk, the output differs from base in 5 values. Each was an object with known properties on base. On #1471 each is One extra case is slower. It is an object with N methods, each returning the same object, then N calls like
The 250, 500, 2,000 and 4,000 rows ran at load 6.0 to 7.5. The 1,000 row ran at load 7.9 to 8.4. Base also grows faster than linear. I did not look for the cause in the source. Three other extra cases cost within 16 percent of base. They were 1,000 calls like The 90 new forms and the 197 older casesNew probe forms and precision costI tested 90 new forms and re-ran the 197 older soundness cases. Both trees are main New probesOf the 90 forms, 89 run in real JavaScript. The 90th is On main, 28 of the 89 give a stale The prefix
Controls for each family hand back a fresh object or a shallow copy. 39 of the 40 keep Read-only calls do lose precision, as the PR body says they may. The control
These forms keep their right answer on both trees:
The PR's new hook sits in the branch for calls and All 90 new forms (main and #1471, Node 24; Node 22 and 26 gave the same cells)
| Precision on the older 197 casesThese are the same 197 cases as the #1444 check. I re-ran their real-JavaScript answers on Node 24, and all 197 equal the stored answers. Main has 9 wrong cases here, the same count as the #1444 check. #1471 fixes 7 of them. It adds no new wrong answer, loses no right answer, and gains none. 190 of the 197 cases give the same answer on both trees.
The 7 fixed cases are the six #1449 cases ( The 7 cases whose answer changed
The 197-case runs used Node 24 and the CLI only. The MCP server was not run. Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
…1517) Since #1471, escaping an object also escapes every method's results. Each call through the object escapes it as the receiver, and each escape re-expanded all of its methods. N methods returning one shared object, each called once, did N times N work: 2,000 calls took 3.0 s of semantic analysis and 4,000 took 12 s. Expansion below references depends only on syntax, so escapes now reuse it per expression and path. Identifiers that resolve to the same binding and path collapse to one, because the escape walk treats them alike. Every escape site is still recorded. The semantic IR is byte-identical on 50 sources, and the issue's case takes 253 ms at 2,000 and 638 ms at 4,000. Closes #1495 Co-authored-by: Claude Opus 5.5 <[email protected]>
) (morluto#1517) Since morluto#1471, escaping an object also escapes every method's results. Each call through the object escapes it as the receiver, and each escape re-expanded all of its methods. N methods returning one shared object, each called once, did N times N work: 2,000 calls took 3.0 s of semantic analysis and 4,000 took 12 s. Expansion below references depends only on syntax, so escapes now reuse it per expression and path. Identifiers that resolve to the same binding and path collapse to one, because the escape walk treats them alike. Every escape site is still recorded. The semantic IR is byte-identical on 50 sources, and the issue's case takes 253 ms at 2,000 and 638 ms at 4,000. Closes morluto#1495
Fixes #1449. Local calls can hand back the same object, but mutation tracking stopped at their results and advertised stale literals after a subsequent write. Resolve candidate return/yield references through the existing escape tracking, sharing the direct-result AST collector with return projection.
The compiled CLI and real stdio MCP regression covers 34 variants: direct and captured calls, property-slot stores, object/class methods, aliases, constructors, recursive wrappers, awaited async results and yielded references. Scalar copies, unrelated containing properties and uninvoked nested callables retain their facts. This is conservative escape analysis: even read-only calls handing back references may become unknown; it does not claim execution or exact post-call values. No schemas, tool inventory or provider behavior change.
Validation: baseline CLI fails with stale
1; fixed public CLI/MCP regression passes, including output-contract validation, Evidence identity, text/structured results, subsequent ping and shutdown. The existing property-store/iteration CLI/MCP journeys also pass; six adjacent source suites pass 353 tests;npm run check:ciand test discovery pass. Controlled fixture execution and public MCP checks pass on Node 22.22.2 and 24.18.0. Real Hopper/Ghidra verification was not performed because this changes pure JavaScript semantics.Related: #1468 independently addresses simple synchronous thunks. This change also covers the property-slot flow explicitly left open there and method/async/generator forms, using iterative AST traversal and the shared return collector.