diff --git a/lib/compress.js b/lib/compress.js index 2a026ba3..4065c543 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -688,6 +688,7 @@ merge(Compressor.prototype, { } else if (parent instanceof AST_Array || parent instanceof AST_Await || parent instanceof AST_Conditional && node !== parent.condition + || parent instanceof AST_Expansion || parent instanceof AST_Sequence && node === parent.tail_node()) { mark_escaped(d, scope, parent, parent, level + 1); } else if (parent instanceof AST_ObjectKeyVal && node === parent.value) { diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index c0713730..080307f5 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -5233,3 +5233,46 @@ escape_await: { })(); } } + +escape_expansion: { + options = { + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + function main() { + var thing = baz(); + if (thing !== (thing = baz())) + console.log("FAIL"); + else + console.log("PASS"); + } + function foo() {} + function bar(...x) { + return x[0]; + } + function baz() { + return bar(...[ foo ]); + } + main(); + } + expect: { + function foo() {} + function baz() { + return function(...x) { + return x[0]; + }(...[ foo ]); + } + (function() { + var thing = baz(); + if (thing !== (thing = baz())) + console.log("FAIL"); + else + console.log("PASS"); + })(); + } + expect_stdout: "PASS" + node_version: ">=6" +}