diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-01-08 07:49:14 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-08 15:49:14 +0800 |
commit | 553034fe52e8c5c07aeaca7a9c97c9fcc3e2435e (patch) | |
tree | 50f968deef8d17d4e8c7a0ef522ec74fe8078c29 | |
parent | 7fe8c9150ac68fb13716e465872ed9e15d7a5126 (diff) | |
download | tracifyjs-553034fe52e8c5c07aeaca7a9c97c9fcc3e2435e.tar.gz tracifyjs-553034fe52e8c5c07aeaca7a9c97c9fcc3e2435e.zip |
fix corner case in `merge_vars` (#4524)
fixes #4523
-rw-r--r-- | lib/compress.js | 7 | ||||
-rw-r--r-- | test/compress/default-values.js | 22 |
2 files changed, 27 insertions, 2 deletions
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" +} |