diff --git a/lib/compress.js b/lib/compress.js index be9b718a..a25c3d66 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -6847,7 +6847,14 @@ Compressor.prototype.compress = function(node) { }); } } - if (node instanceof AST_Call) calls_to_drop_args.push(node); + if (node instanceof AST_Call) { + calls_to_drop_args.push(node); + node.args = node.args.map(function(arg) { + return arg.transform(tt); + }); + node.expression = node.expression.transform(tt); + return node; + } if (scope !== self) return; if (drop_funcs && node !== self && node instanceof AST_DefClass) { var def = node.name.definition(); diff --git a/test/compress/rests.js b/test/compress/rests.js index 98a640e8..056d8c8a 100644 --- a/test/compress/rests.js +++ b/test/compress/rests.js @@ -1323,3 +1323,43 @@ issue_5370: { expect_stdout: true node_version: ">=6" } + +issue_5391: { + options = { + evaluate: true, + keep_fargs: false, + objects: true, + pure_getters: "strict", + reduce_vars: true, + side_effects: true, + toplevel: true, + unused: true, + } + input: { + var a, b = function f({ + p: {}, + ...c + }) { + while (c.q); + }({ + p: { + r: a++, + r: 0, + } + }); + console.log(a); + } + expect: { + (function({ + p: {}, + ...c + }) { + while (c.q); + })({ + p: 0, + }); + console.log(NaN); + } + expect_stdout: "NaN" + node_version: ">=8.3.0" +}