reduce AST_ForIn gracefully (#4087)
This commit is contained in:
@@ -112,19 +112,18 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
|||||||
// no structural AST changes before this point.
|
// no structural AST changes before this point.
|
||||||
if (node.start._permute >= REPLACEMENTS.length) return;
|
if (node.start._permute >= REPLACEMENTS.length) return;
|
||||||
|
|
||||||
if (parent instanceof U.AST_Assign
|
// ignore lvalues
|
||||||
&& parent.left === node
|
if (parent instanceof U.AST_Assign && parent.left === node) return;
|
||||||
|| parent instanceof U.AST_Unary
|
if (parent instanceof U.AST_Unary && parent.expression === node) switch (parent.operator) {
|
||||||
&& parent.expression === node
|
case "++":
|
||||||
&& ["++", "--", "delete"].indexOf(parent.operator) >= 0) {
|
case "--":
|
||||||
// ignore lvalues
|
case "delete":
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((parent instanceof U.AST_For || parent instanceof U.AST_ForIn)
|
// preserve for (var xxx; ...)
|
||||||
&& parent.init === node && node instanceof U.AST_Var) {
|
if (parent instanceof U.AST_For && parent.init === node && node instanceof U.AST_Var) return node;
|
||||||
// preserve for (var ...)
|
// preserve for (xxx in ...)
|
||||||
return node;
|
if (parent instanceof U.AST_ForIn && parent.init === node) return node;
|
||||||
}
|
|
||||||
|
|
||||||
// node specific permutations with no parent logic
|
// node specific permutations with no parent logic
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user