From: Alex Lam S.L Date: Thu, 19 Nov 2020 22:23:37 +0000 (+0000) Subject: fix corner case in `collapse_vars` (#4309) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=1b579779be52116a029622156c0217ef33b95f86;p=UglifyJS.git fix corner case in `collapse_vars` (#4309) fixes #4308 --- diff --git a/lib/compress.js b/lib/compress.js index 90488807..601f39f0 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1825,7 +1825,11 @@ merge(Compressor.prototype, { name: sym, value: arg })); - if (sym instanceof AST_Destructured) continue; + if (sym instanceof AST_Destructured) { + if (!sym.match_symbol(return_false)) continue; + candidates.length = 0; + break; + } if (sym.name in names) continue; names[sym.name] = true; if (!arg) { diff --git a/test/compress/destructured.js b/test/compress/destructured.js index bbe62a71..f8e8090d 100644 --- a/test/compress/destructured.js +++ b/test/compress/destructured.js @@ -1591,3 +1591,28 @@ issue_4301: { expect_stdout: true node_version: ">=6" } + +issue_4308: { + options = { + collapse_vars: true, + unused: true, + } + input: { + var a = "PASS"; + console.log(function({ + [a = "FAIL"]: b + }, c) { + return c; + }(0, a)); + } + expect: { + var a = "PASS"; + console.log(function({ + [a = "FAIL"]: b + }, c) { + return c; + }(0, a)); + } + expect_stdout: "PASS" + node_version: ">=6" +}