fix corner case in reduce_vars

fixes #4581
This commit is contained in:
alexlamsl 2021-01-23 00:47:10 +08:00
parent 0358637725
commit 6998983b59
2 changed files with 22 additions and 1 deletions

View File

@ -719,7 +719,7 @@ merge(Compressor.prototype, {
var fn = this; var fn = this;
fn.inlined = false; fn.inlined = false;
var iife = tw.parent(); var iife = tw.parent();
var hit = fn instanceof AST_AsyncFunction; var hit = is_async(fn);
var aborts = false; var aborts = false;
fn.walk(new TreeWalker(function(node) { fn.walk(new TreeWalker(function(node) {
if (hit) return aborts = true; if (hit) return aborts = true;

View File

@ -1003,3 +1003,24 @@ issue_4534: {
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=8" node_version: ">=8"
} }
issue_4581: {
options = {
evaluate: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var a = "PASS";
(async () => (A, a = "FAIL"))();
console.log(a);
}
expect: {
var a = "PASS";
(async () => (A, a = "FAIL"))();
console.log(a);
}
expect_stdout: "PASS"
node_version: ">=8"
}