From f345175bc2aef3cb9d3ceb6ec241cf191dd70eb7 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Fri, 25 Dec 2020 11:27:05 +0000 Subject: [PATCH] fix corner case in `merge_vars` (#4455) fixes #4454 --- lib/compress.js | 2 +- test/compress/async.js | 56 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/lib/compress.js b/lib/compress.js index 33aa5b91..0718e5c7 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -5187,7 +5187,7 @@ merge(Compressor.prototype, { } else if ((ldef = self.variables.get(def.name)) !== def) { if (ldef && root === segment) references[ldef.id] = false; return references[def.id] = false; - } else if (compressor.exposed(def) || sym.name == "arguments") { + } else if (compressor.exposed(def) || sym.name == "arguments" || sym.name == "await") { return references[def.id] = false; } else { var refs = declarations.get(def.id) || []; diff --git a/test/compress/async.js b/test/compress/async.js index bf4d55c8..19b90f51 100644 --- a/test/compress/async.js +++ b/test/compress/async.js @@ -640,3 +640,59 @@ issue_4417: { expect_stdout: "undefined" node_version: ">=8" } + +issue_4454_1: { + rename = false + options = { + merge_vars: true, + } + input: { + function f(a) { + (async function(b = console.log(a)) {})(); + var await = 42..toString(); + console.log(await); + } + f("PASS"); + } + expect: { + function f(a) { + (async function(b = console.log(a)) {})(); + var await = 42..toString(); + console.log(await); + } + f("PASS"); + } + expect_stdout: [ + "PASS", + "42", + ] + node_version: ">=8" +} + +issue_4454_2: { + rename = true + options = { + merge_vars: true, + } + input: { + function f(a) { + (async function(b = console.log(a)) {})(); + var await = 42..toString(); + console.log(await); + } + f("PASS"); + } + expect: { + function f(b) { + (async function(c = console.log(b)) {})(); + var b = 42..toString(); + console.log(b); + } + f("PASS"); + } + expect_stdout: [ + "PASS", + "42", + ] + node_version: ">=8" +} -- 2.34.1