From f87e7be12c7857ec0fc772a9ea4db6d24b5e3551 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Fri, 22 Jan 2021 18:14:53 +0000 Subject: [PATCH] fix corner case in `reduce_vars` (#4582) fixes #4581 --- lib/compress.js | 2 +- test/compress/awaits.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/compress.js b/lib/compress.js index fc1bc118..547ef574 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -719,7 +719,7 @@ merge(Compressor.prototype, { var fn = this; fn.inlined = false; var iife = tw.parent(); - var hit = fn instanceof AST_AsyncFunction; + var hit = is_async(fn); var aborts = false; fn.walk(new TreeWalker(function(node) { if (hit) return aborts = true; diff --git a/test/compress/awaits.js b/test/compress/awaits.js index 4a90ca5e..0ffa1a9b 100644 --- a/test/compress/awaits.js +++ b/test/compress/awaits.js @@ -1003,3 +1003,24 @@ issue_4534: { expect_stdout: "PASS" 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" +} -- 2.34.1