fix corner case in collapse_vars (#3745)

fixes #3744
This commit is contained in:
Alex Lam S.L
2020-03-06 18:27:06 +00:00
committed by GitHub
parent bca52fcba2
commit bdc8ef2218
2 changed files with 45 additions and 1 deletions

View File

@@ -1384,7 +1384,10 @@ merge(Compressor.prototype, {
function is_last_node(node, parent) {
if (node instanceof AST_Call) {
var fn = node.expression;
if (fn instanceof AST_SymbolRef) fn = fn.fixed_value();
if (fn instanceof AST_SymbolRef) {
if (fn.definition().recursive_refs > 0) return true;
fn = fn.fixed_value();
}
if (!(fn instanceof AST_Lambda)) return true;
if (fn.collapse_scanning) return false;
fn.collapse_scanning = true;

View File

@@ -7765,3 +7765,44 @@ issue_3700: {
}
expect_stdout: "PASS"
}
issue_3744: {
options = {
collapse_vars: true,
inline: true,
reduce_vars: true,
unused: true,
}
input: {
(function f(a) {
({
get p() {
switch (1) {
case 0:
f((a = 2, 3));
case 1:
console.log(function g(b) {
return b || "PASS";
}());
}
}
}).p;
})();
}
expect: {
(function f(a) {
({
get p() {
switch (1) {
case 0:
f();
case 1:
console.log(b || "PASS");
}
var b;
}
}).p;
})();
}
expect_stdout: "PASS"
}