fix(javascript): converge cyclic aliases with explicit projection widening

Replace initializer-history and full-path enumeration with a finite projection
join at each source read. Retain conservative local returned-reference effects
and disclose precision loss through static, semantic and captured-web results.
Close full-binding callback cycles while preserving narrowed read semantics.

Fixes #4348
Fixes #5138
Refs #4349
Refs #4364

Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Fuxuan-CN <3072252442@qq.com>
This commit is contained in:
committed 2026-10-19 12:26:54 +08:00
1 parent 9af0b6113c
commit e4c3d72396
19 files changed
+791 -166

No files matched your search

@@ -0,0 +1,33 @@
import { expect, it } from "vitest";
import { analyzeJavaScriptSemantics } from "./javascriptSemanticAnalysis.js";
import { analyzeJavaScriptStaticSource } from "./javascriptStaticAnalysis.js";
import { RETURNED_REFERENCE_WIDENING_LIMITATION } from "./javascriptSemanticCoverage.js";
it("preserves possible ambient effects and discloses projection widening in source coverage", () => {
const source = `
function expose() { return Map.prototype; }
let cursor = { target: expose };
function walk(flag) {
while (flag) cursor = cursor.next;
patch(cursor.target());
}
fetch('/preserved');
new Map().get('/candidate');
`;
const ir = analyzeJavaScriptSemantics(source);
expect(ir.coverage).toMatchObject({ status: "partial", omittedCount: 0 });
expect(ir.coverage.widenedReturnedReferences?.length).toBeGreaterThan(0);
expect(ir.limitations).toContain(RETURNED_REFERENCE_WIDENING_LIMITATION);
const facts = analyzeJavaScriptStaticSource(source);
expect(facts.limitations).toContain(RETURNED_REFERENCE_WIDENING_LIMITATION);
expect(facts.endpoints).toEqual(
expect.arrayContaining([
expect.objectContaining({ value: "/preserved", mechanism: "call:fetch" }),
expect.objectContaining({
value: "/candidate",
interpretation: "candidate",
}),
]),
);
});