Skip to content

Commit c8b0f68

Browse files
authored
fix corner case in merge_vars (#5143)
fixes #5142
1 parent 87b9916 commit c8b0f68

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

lib/compress.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5694,7 +5694,7 @@ merge(Compressor.prototype, {
56945694
if (node instanceof AST_Call) {
56955695
var exp = node.expression;
56965696
var tail = exp.tail_node();
5697-
if (!(tail instanceof AST_LambdaExpression)) {
5697+
if (!is_lambda(tail)) {
56985698
descend();
56995699
return mark_expression(exp);
57005700
}

test/compress/classes.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,3 +2066,34 @@ issue_5082_2: {
20662066
expect_stdout: "PASS"
20672067
node_version: ">=12"
20682068
}
2069+
2070+
issue_5142: {
2071+
options = {
2072+
evaluate: true,
2073+
merge_vars: true,
2074+
reduce_vars: true,
2075+
toplevel: true,
2076+
}
2077+
input: {
2078+
var a = 0, b;
2079+
if (++a)
2080+
new class {
2081+
p = b = null;
2082+
constructor(c) {
2083+
console.log(c ? "FAIL" : "PASS");
2084+
}
2085+
}(b, a);
2086+
}
2087+
expect: {
2088+
var a = 0, b;
2089+
if (++a)
2090+
new class {
2091+
p = b = null;
2092+
constructor(c) {
2093+
console.log(c ? "FAIL" : "PASS");
2094+
}
2095+
}(b, 1);
2096+
}
2097+
expect_stdout: "PASS"
2098+
node_version: ">=12"
2099+
}

0 commit comments

Comments
 (0)