mirror of
https://github.com/morluto/rea.git
synced 2026-11-30 10:27:42 +00:00
fix(javascript): escape values stored into an object that escapes (#14273)
* fix(javascript): escape values stored into an object that escapes An escape followed an object's initializers but not the values member writes stored into it, so `x.a = y; unknown(x)` kept `y`'s members literal. An escape now also escapes the stored values at or below the escaped path. The effect log names the store paths, and the projected-source owner selects the stores the escape site can see. A collapsed escape names no site, so it escapes every value a reference store put at or below its path, once for all collapsed queries. An escaped path that initializers never reach stays pruned unless a store targets it or a path below it. Stores inside a destructuring site's pattern stay with the pattern's iterator and close owners, and operator results are skipped because they are primitive. Fixes #14152 * perf(javascript): classify reference stores once per binding --------- Co-authored-by: Ysopwnable <161784452+N0zoM1z0@users.noreply.github.com>
This commit is contained in:
1 parent
2c07552b64
commit
26741b03be
4 files changed
+258
-1
No files matched your search
@@ -715,6 +715,63 @@ describe("JavaScript semantic values after mutable references escape", () => {
|
||||
`)?.status,
|
||||
).toBe("unknown");
|
||||
});
|
||||
|
||||
it.each([
|
||||
["the escaped object", "const holder = {}; holder.child = source;"],
|
||||
[
|
||||
"an alias of the escaped object",
|
||||
"const holder = {}; const alias = holder; alias.child = source;",
|
||||
],
|
||||
[
|
||||
"a nested slot of the escaped object",
|
||||
"const holder = { box: {} }; holder.box.child = source;",
|
||||
],
|
||||
["a computed slot", "const holder = {}; holder[key] = source;"],
|
||||
])("follows a value stored into %s before it escapes", (_name, store) => {
|
||||
expect(
|
||||
resultValue(`
|
||||
const source = { value: 1 };
|
||||
${store}
|
||||
mutate(holder);
|
||||
return source.value;
|
||||
`)?.status,
|
||||
).toBe("unknown");
|
||||
});
|
||||
|
||||
it("follows a stored value when the slot holding it escapes", () => {
|
||||
expect(
|
||||
resultValue(`
|
||||
const source = { value: 1 };
|
||||
const holder = {};
|
||||
holder.child = source;
|
||||
mutate(holder.child);
|
||||
return source.value;
|
||||
`)?.status,
|
||||
).toBe("unknown");
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
"a sibling slot escapes",
|
||||
"const holder = { other: {} }; holder.child = source; mutate(holder.other);",
|
||||
],
|
||||
[
|
||||
"the store follows the escape",
|
||||
"const holder = {}; mutate(holder); holder.child = source;",
|
||||
],
|
||||
[
|
||||
"only a child of the stored value escapes",
|
||||
"const holder = {}; holder.child = source; mutate(holder.child.nested);",
|
||||
],
|
||||
])("keeps a stored value known when %s", (_name, body) => {
|
||||
expect(
|
||||
resultValue(`
|
||||
const source = { value: 1, nested: {} };
|
||||
${body}
|
||||
return source.value;
|
||||
`),
|
||||
).toEqual({ status: "literal", value: 1 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("JavaScript escaped references through async and destructuring syntax", () => {
|
||||
|
||||
Reference in new issue
Block a user