fix corner case in merge_vars (#5092)

fixes #5091
This commit is contained in:
Alex Lam S.L
2021-07-20 19:47:53 +01:00
committed by GitHub
parent 8926a2f327
commit 7fac839c62
2 changed files with 44 additions and 5 deletions

View File

@@ -5672,7 +5672,10 @@ merge(Compressor.prototype, {
if (node instanceof AST_Call) {
var exp = node.expression;
var tail = exp.tail_node();
if (!(tail instanceof AST_LambdaExpression)) return walk_node_with_expr(node);
if (!(tail instanceof AST_LambdaExpression)) {
descend();
return mark_expression(exp);
}
if (exp !== tail) exp.expressions.slice(0, -1).forEach(function(node) {
node.walk(tw);
});
@@ -5788,7 +5791,18 @@ merge(Compressor.prototype, {
pop();
return true;
}
if (node instanceof AST_Sub) return walk_node_with_expr(node);
if (node instanceof AST_Sub) {
var exp = node.expression;
if (node.optional) {
exp.walk(tw);
push();
node.property.walk(tw);
pop();
} else {
descend();
}
return mark_expression(exp);
}
if (node instanceof AST_Switch) {
node.expression.walk(tw);
var save = segment;
@@ -5888,10 +5902,9 @@ merge(Compressor.prototype, {
return true;
}
function walk_node_with_expr(node) {
descend();
function mark_expression(exp) {
if (compressor.option("ie")) {
var sym = root_expr(node.expression);
var sym = root_expr(exp);
if (sym instanceof AST_SymbolRef) sym.walk(tw);
}
return true;