diff options
-rw-r--r-- | lib/compress.js | 6 | ||||
-rw-r--r-- | test/compress/rests.js | 22 |
2 files changed, 26 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js index c19091d7..3820a3ad 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -12313,8 +12313,10 @@ merge(Compressor.prototype, { OPT(AST_DestructuredArray, function(self, compressor) { if (compressor.option("rests") && self.rest instanceof AST_DestructuredArray) { - self.elements = self.elements.concat(self.rest.elements); - self.rest = self.rest.rest; + return make_node(AST_DestructuredArray, self, { + elements: self.elements.concat(self.rest.elements), + rest: self.rest.rest, + }); } return self; }); diff --git a/test/compress/rests.js b/test/compress/rests.js index 45d8e222..a62e380a 100644 --- a/test/compress/rests.js +++ b/test/compress/rests.js @@ -1069,3 +1069,25 @@ issue_5100_2: { expect_stdout: "PASS" node_version: ">=10" } + +issue_5108: { + options = { + evaluate: true, + reduce_vars: true, + rests: true, + unsafe: true, + unused: true, + } + input: { + console.log(function([ ...[ a ] ]) { + return a; + }([ "PASS", "FAIL" ])); + } + expect: { + console.log(function([]) { + return "PASS"; + }([ "PASS", "FAIL" ])); + } + expect_stdout: "PASS" + node_version: ">=6" +} |