From c44b6399c30b043f9bf687ce9b44458abc211d80 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sun, 7 Feb 2021 14:40:41 +0000 Subject: [PATCH] fix corner case in `side_effects` (#4622) fixes #4621 --- lib/compress.js | 2 +- test/compress/rests.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/compress.js b/lib/compress.js index 7a6a0bcb..afb555f0 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -8295,7 +8295,7 @@ merge(Compressor.prototype, { if (has_arg_refs(argname)) return false; } return true; - }); + }) && !(fn.rest instanceof AST_Destructured && has_arg_refs(fn.rest)); var can_inline = can_drop && compressor.option("inline") && !self.is_expr_pure(compressor); if (can_inline && stat instanceof AST_Return) { var value = stat.value; diff --git a/test/compress/rests.js b/test/compress/rests.js index 42e62953..21adf204 100644 --- a/test/compress/rests.js +++ b/test/compress/rests.js @@ -696,3 +696,21 @@ issue_4575: { expect_stdout: "PASS 0" node_version: ">=6" } + +issue_4621: { + options = { + side_effects: true, + } + input: { + (function f(a, ...{ + [console.log(a)]: b, + }) {})("PASS"); + } + expect: { + (function f(a, ...{ + [console.log(a)]: b, + }) {})("PASS"); + } + expect_stdout: "PASS" + node_version: ">=6" +} -- 2.34.1