From 76ac9b3d88e1902f24844629d4bbb5ed1595c30f Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Wed, 6 Jan 2021 00:00:07 +0800 Subject: [PATCH] fix corner case in `side_effects` fixes #4512 --- lib/compress.js | 10 +--------- test/compress/destructured.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/compress.js b/lib/compress.js index 1714306e..5ba240e2 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -8072,15 +8072,7 @@ merge(Compressor.prototype, { } if (argname instanceof AST_Destructured) { has_destructured = true; - var abort = false; - argname.walk(new TreeWalker(function(node) { - if (abort) return true; - if (node instanceof AST_DestructuredKeyVal) { - var key = node.key; - if (key instanceof AST_Node && has_arg_refs(key)) return abort = true; - } - })); - if (abort) return false; + if (has_arg_refs(argname)) return false; } return true; }); diff --git a/test/compress/destructured.js b/test/compress/destructured.js index a476705d..4f6a9f2f 100644 --- a/test/compress/destructured.js +++ b/test/compress/destructured.js @@ -2384,3 +2384,17 @@ issue_4508: { ] node_version: ">=6" } + +issue_4512: { + options = { + side_effects: true, + } + input: { + console.log(function([ a, b = a ]) {}([])); + } + expect: { + console.log(function([ a, b = a ]) {}([])); + } + expect_stdout: "undefined" + node_version: ">=6" +}