fix corner case in merge_vars (#5143)

fixes #5142
This commit is contained in:
Alex Lam S.L
2021-10-04 17:42:46 +01:00
committed by GitHub
parent 87b99162fb
commit c8b0f685ee
2 changed files with 32 additions and 1 deletions

View File

@@ -5694,7 +5694,7 @@ merge(Compressor.prototype, {
if (node instanceof AST_Call) {
var exp = node.expression;
var tail = exp.tail_node();
if (!(tail instanceof AST_LambdaExpression)) {
if (!is_lambda(tail)) {
descend();
return mark_expression(exp);
}

View File

@@ -2066,3 +2066,34 @@ issue_5082_2: {
expect_stdout: "PASS"
node_version: ">=12"
}
issue_5142: {
options = {
evaluate: true,
merge_vars: true,
reduce_vars: true,
toplevel: true,
}
input: {
var a = 0, b;
if (++a)
new class {
p = b = null;
constructor(c) {
console.log(c ? "FAIL" : "PASS");
}
}(b, a);
}
expect: {
var a = 0, b;
if (++a)
new class {
p = b = null;
constructor(c) {
console.log(c ? "FAIL" : "PASS");
}
}(b, 1);
}
expect_stdout: "PASS"
node_version: ">=12"
}