fix corner case in collapse_vars (#4391)

fixes #4390
This commit is contained in:
Alex Lam S.L
2020-12-17 19:10:16 +00:00
committed by GitHub
parent 02fdcfde01
commit ab82be82b2
2 changed files with 32 additions and 1 deletions

View File

@@ -1776,7 +1776,9 @@ merge(Compressor.prototype, {
can_replace = false;
var after = stop_after;
var if_hit = stop_if_hit;
for (var i = 0; !abort && i < fn.body.length; i++) {
if (fn instanceof AST_Arrow && fn.value) {
fn.value.transform(scanner);
} else for (var i = 0; !abort && i < fn.body.length; i++) {
var stat = fn.body[i];
if (stat instanceof AST_Return) {
if (stat.value) stat.value.transform(scanner);

View File

@@ -351,3 +351,32 @@ issue_4388: {
expect_stdout: "undefined"
node_version: ">=4"
}
issue_4390: {
options = {
collapse_vars: true,
}
input: {
function log() {
console.log.apply(console, arguments);
}
var a = 42, b = "FAIL";
b = "PASS";
(c => log(b, c))(a);
log(b);
}
expect: {
function log() {
console.log.apply(console, arguments);
}
var a = 42, b = "FAIL";
b = "PASS";
(c => log(b, c))(a);
log(b);
}
expect_stdout: [
"PASS 42",
"PASS",
]
node_version: ">=4"
}