fix(javascript): preserve abrupt destructuring boundaries (#13433)

* fix(javascript): preserve abrupt destructuring boundaries

* test(javascript): consolidate destructuring Evidence trace checks

* fix(javascript): evaluate computed nullish receivers
This commit is contained in:
morluto authored and GitHub committed 2026-11-22 14:21:09 +00:00
1 parent 3db9120c5e
commit 365bbd9008
4 files changed
+182 -166

No files matched your search

@@ -31,12 +31,21 @@ it.each([
["null", "{} = {}"],
["undefined", "{} = null"],
["void 0", "[] = undefined"],
["aliasedNull", "{} = {}"],
["true ? null : {}", "{}"],
["undefined", "{} = (false ? {} : null)"],
["undefined", "{} = aliasedNull"],
["null", "{}", '["bad"]'],
["captured", "{}", "bad", "captured = {};"],
] as const)(
"leaves bindings after %s matched against %s unproven",
(value, pattern) => {
(value, pattern, key = "bad", afterCapture?: string) => {
const inspect = projection(`
const aliasedNull = null;
let captured = null;
const model = { bad: ${value}, mode: "one" };
const { mode: before, bad: ${pattern}, mode: selected } = model;
${afterCapture ?? ""}
const { mode: before, ${key}: ${pattern}, mode: selected } = model;
`);
expect(inspect("before")).toMatchObject({
resolution: "resolved",
@@ -53,10 +62,15 @@ it.each([
it.each([
["const model = { bad: 0, mode: 'one' };", "{}"],
["const model = { bad: {}, mode: 'one' };", "{}"],
["const model = { bad: true ? {} : null, mode: 'one' };", "{}"],
["const model = { bad: [], mode: 'one' };", "[]"],
["const model = { bad: undefined, mode: 'one' };", "{} = {}"],
["const model = { bad: 0, mode: 'one' };", "{} = null"],
["const undefined = 0; const model = { bad: undefined, mode: 'one' };", "{}"],
[
"let captured = {}; const model = { bad: captured, mode: 'one' }; captured = null;",
"{}",
],
] as const)(
"preserves the reachable sibling for %s against %s",
(setup, pattern) => {
@@ -415,7 +415,6 @@ it.each(["{}", "unknownSource"])(
);
it.each([
["ordinary array", "", "resolved"],
["prototype read alone", "Object.getPrototypeOf([].values());", "resolved"],
[
"one iterator's own next",
@@ -715,24 +714,6 @@ it.each([
},
);
it("leaves an earlier destructuring dependency intact before an iterator prototype write", () => {
const graph = graphForJavaScript(`
const config = ["original"];
const [selected] = config;
Object.getPrototypeOf([].values()).next = () => ({ value: "other", done: false });
`);
const selected = graph.nodes.find(
({ kind, label }) => kind === "binding" && label === "selected",
);
expect(
graph.relations.find(
(relation) =>
relation.relation === "destructures" &&
relation.target_node_id === selected?.node_id,
),
).toMatchObject({ resolution: "resolved" });
});
it.each([
["declaration", "const [selected] = config;", "resolved"],
["assignment", "let selected; [selected] = config;", "resolved"],