properly cover all cases of for-in loop variables (#1536)
This commit is contained in:
@@ -243,13 +243,13 @@ merge(Compressor.prototype, {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (node instanceof AST_ForIn) {
|
if (node instanceof AST_ForIn) {
|
||||||
if (node.init instanceof AST_SymbolRef) {
|
var sym = node.init;
|
||||||
var d = node.init.definition();
|
if (sym instanceof AST_Var) {
|
||||||
d.references.push(node.init);
|
sym = sym.definitions[0].name;
|
||||||
d.fixed = false;
|
|
||||||
} else {
|
|
||||||
node.init.walk(tw);
|
|
||||||
}
|
}
|
||||||
|
var d = sym.definition();
|
||||||
|
d.references.push(sym);
|
||||||
|
d.fixed = false;
|
||||||
node.object.walk(tw);
|
node.object.walk(tw);
|
||||||
push();
|
push();
|
||||||
node.body.walk(tw);
|
node.body.walk(tw);
|
||||||
|
|||||||
@@ -563,7 +563,7 @@ inner_var_for: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inner_var_for_in: {
|
inner_var_for_in_1: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
@@ -590,6 +590,21 @@ inner_var_for_in: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inner_var_for_in_2: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
for (var long_name in {})
|
||||||
|
console.log(long_name);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
for (var long_name in {})
|
||||||
|
console.log(long_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
issue_1533_1: {
|
issue_1533_1: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user