From: Alex Lam S.L Date: Fri, 8 Jan 2021 07:49:14 +0000 (+0000) Subject: fix corner case in `merge_vars` (#4524) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=553034fe52e8c5c07aeaca7a9c97c9fcc3e2435e;p=UglifyJS.git fix corner case in `merge_vars` (#4524) fixes #4523 --- diff --git a/lib/compress.js b/lib/compress.js index bcffd8b8..8652d6e4 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4957,7 +4957,10 @@ merge(Compressor.prototype, { node.right.walk(tw); var marker = new TreeWalker(function(node) { if (node instanceof AST_Destructured) return; - if (node instanceof AST_DestructuredKeyVal) { + if (node instanceof AST_DefaultValue) { + node.value.walk(tw); + node.name.walk(marker); + } else if (node instanceof AST_DestructuredKeyVal) { if (node.key instanceof AST_Node) { push(); segment.block = node; @@ -5177,7 +5180,7 @@ merge(Compressor.prototype, { node.name.mark_symbol(node.value ? function(node) { if (!(node instanceof AST_SymbolDeclaration)) return; if (node instanceof AST_SymbolVar) { - mark(node, false); + mark(node); } else { references[node.definition().id] = false; } diff --git a/test/compress/default-values.js b/test/compress/default-values.js index 8e5910d9..23e31748 100644 --- a/test/compress/default-values.js +++ b/test/compress/default-values.js @@ -1527,3 +1527,25 @@ issue_4510_2: { expect_stdout: "PASS" node_version: ">=8" } + +issue_4523: { + options = { + merge_vars: true, + } + input: { + console.log(function() { + var a, b; + [ a = b = false ] = [ "FAIL" ]; + return b || "PASS"; + }()); + } + expect: { + console.log(function() { + var a, b; + [ a = b = false ] = [ "FAIL" ]; + return b || "PASS"; + }()); + } + expect_stdout: "PASS" + node_version: ">=6" +}