fix(javascript): retain proven property presence at reads (#12477)

* fix(javascript): retain proven property presence at reads

The read-time IR and projection boundary builds on the destructuring work in #7716. This change adds an indexed own-slot proof and uses it for ordinary member reads as well.

Co-authored-by: SII-YDD <38822679+SII-YDD@users.noreply.github.com>

* fix(javascript): retain destructuring proof in read order

---------

Co-authored-by: SII-YDD <38822679+SII-YDD@users.noreply.github.com>
This commit is contained in:
morlutoandSII-YDD authored and GitHub committed 2026-11-19 19:17:32 +00:00
1 parent 833916bb4a
commit 1dc22f18cd
8 files changed
+322 -42

No files matched your search

@@ -8,7 +8,7 @@ import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { cliTest } from "../../support/cli/cliFixture.js";
cliTest(
"retains assignment and nested-default destructuring Evidence",
"retains earlier property dependencies through analysis and default tracing",
async ({ cli }) => {
const root = await createTestTempDirectory(
"rea-js-destructuring-evidence-",
@@ -17,9 +17,11 @@ cliTest(
join(root, "main.js"),
`
const src = { a: 1 };
const { a: declared } = src;
const { a: declared, laterDefault = 0 } = src;
let a;
({ a } = src);
const direct = src.a;
src.a = 2;
const nested = { a: [1], b: 2 };
const { a: [plain] } = nested;
const { a: [fallback] = [] } = nested;
@@ -58,5 +60,36 @@ cliTest(
)?.properties.property_path,
).toEqual(path);
}
expect(
graph.relations.find(({ relation }) => relation === "reads-property"),
).toMatchObject({ resolution: "resolved" });
const declared = graph.nodes.find(
({ kind, label }) => kind === "binding" && label === "declared",
);
const queryPath = join(root, "query.json");
await writeFile(
queryPath,
JSON.stringify({
application: output.json,
query: {
seed: { kind: "semantic-node", node_id: declared?.node_id },
direction: "backward-provenance",
},
}),
);
const trace = await cli.run({
arguments: ["trace-javascript-semantics", queryPath, "--json"],
});
expect(trace.exitCode, trace.stderr).toBe(0);
expect(trace.json).toMatchObject({
normalized_result: {
relations: expect.arrayContaining([
expect.objectContaining({
relation: "destructures",
resolution: "resolved",
}),
]),
},
});
},
);