fix escape analysis for AST_Expansion
This commit is contained in:
@@ -688,6 +688,7 @@ merge(Compressor.prototype, {
|
||||
} else if (parent instanceof AST_Array
|
||||
|| parent instanceof AST_Await
|
||||
|| parent instanceof AST_Conditional && node !== parent.condition
|
||||
|| parent instanceof AST_Expansion
|
||||
|| parent instanceof AST_Sequence && node === parent.tail_node()) {
|
||||
mark_escaped(d, scope, parent, parent, level + 1);
|
||||
} else if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
|
||||
|
||||
@@ -5233,3 +5233,46 @@ escape_await: {
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
escape_expansion: {
|
||||
options = {
|
||||
reduce_funcs: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function main() {
|
||||
var thing = baz();
|
||||
if (thing !== (thing = baz()))
|
||||
console.log("FAIL");
|
||||
else
|
||||
console.log("PASS");
|
||||
}
|
||||
function foo() {}
|
||||
function bar(...x) {
|
||||
return x[0];
|
||||
}
|
||||
function baz() {
|
||||
return bar(...[ foo ]);
|
||||
}
|
||||
main();
|
||||
}
|
||||
expect: {
|
||||
function foo() {}
|
||||
function baz() {
|
||||
return function(...x) {
|
||||
return x[0];
|
||||
}(...[ foo ]);
|
||||
}
|
||||
(function() {
|
||||
var thing = baz();
|
||||
if (thing !== (thing = baz()))
|
||||
console.log("FAIL");
|
||||
else
|
||||
console.log("PASS");
|
||||
})();
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user