mirror of
https://github.com/morluto/rea.git
synced 2026-11-21 06:04:03 +00:00
fix(javascript): preserve nested array iterator dependencies (#12558)
* fix(javascript): preserve nested array iterator dependencies * fix(javascript): retain reflected array prototype identity * fix(javascript): guard native arrays with ambient prototype effects Reuse the shared effect-log classifier first prepared for dense inline spread analysis. * test(javascript): keep array prototype alias fixture with sources
This commit is contained in:
1 parent
a035813e55
commit
473b3ee10e
8 files changed
+256
-33
No files matched your search
@@ -26,6 +26,17 @@ const iteratorCloseSource = `
|
||||
const { useCustom = (holder.parent.items = custom), items: [read], next: { mode: projectedAfterAcquisition } } = holder.parent;
|
||||
`;
|
||||
|
||||
const arrayPrototypeAliasSource = `
|
||||
change();
|
||||
function change() {
|
||||
const proto = Reflect.getPrototypeOf([]);
|
||||
proto[Symbol.iterator] = function* () {};
|
||||
}
|
||||
const pairs = [["first"]];
|
||||
const [[aliasedPrototypeElement]] = pairs;
|
||||
pairs[0][0] = "later";
|
||||
`;
|
||||
|
||||
const expectedDependencies = [
|
||||
["declared", ["a"]],
|
||||
["a", ["a"]],
|
||||
@@ -38,6 +49,8 @@ const expectedDependencies = [
|
||||
["projected", ["items", "0"]],
|
||||
["arrayObject", ["0", "mode"]],
|
||||
["nestedElement", ["items", "0"]],
|
||||
["innerElement", ["0", "0"]],
|
||||
["aliasedPrototypeElement", ["0", "0"], "candidate"],
|
||||
["selected", ["0"], "candidate"],
|
||||
["beforeClose", ["label"]],
|
||||
["consumed", ["items", "0", "mode"]],
|
||||
@@ -93,6 +106,9 @@ cliTest(
|
||||
const nestedSource = { items: ["nested"] };
|
||||
const { items: [nestedElement] } = nestedSource;
|
||||
nestedSource.items[0] = "later";
|
||||
const nestedPairs = [["read-time"]];
|
||||
const [[innerElement]] = nestedPairs;
|
||||
nestedPairs[0][0] = "later";
|
||||
const box = { items: [] };
|
||||
const iterator = box.items.values();
|
||||
const prototype = Reflect.getPrototypeOf(iterator);
|
||||
@@ -105,6 +121,10 @@ cliTest(
|
||||
`,
|
||||
);
|
||||
await writeFile(join(root, "iterator-close.js"), iteratorCloseSource);
|
||||
await writeFile(
|
||||
join(root, "array-prototype-alias.js"),
|
||||
arrayPrototypeAliasSource,
|
||||
);
|
||||
const output = await cli.run({
|
||||
arguments: ["analyze-javascript-application", root, "--json"],
|
||||
});
|
||||
@@ -150,6 +170,8 @@ cliTest(
|
||||
"projected",
|
||||
"arrayObject",
|
||||
"nestedElement",
|
||||
"innerElement",
|
||||
"aliasedPrototypeElement",
|
||||
"selected",
|
||||
"beforeClose",
|
||||
"consumed",
|
||||
@@ -182,7 +204,11 @@ cliTest(
|
||||
]),
|
||||
},
|
||||
};
|
||||
if (name === "selected" || name === "afterClose")
|
||||
if (
|
||||
name === "selected" ||
|
||||
name === "afterClose" ||
|
||||
name === "aliasedPrototypeElement"
|
||||
)
|
||||
expect(trace.json).not.toMatchObject(relation);
|
||||
else expect(trace.json).toMatchObject(relation);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user