diff options
-rw-r--r-- | lib/compress.js | 7 | ||||
-rw-r--r-- | lib/parse.js | 1 | ||||
-rw-r--r-- | test/compress/arrows.js | 9 | ||||
-rw-r--r-- | test/compress/rests.js | 27 |
4 files changed, 41 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js index 325c0cd0..c3e315de 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -762,10 +762,11 @@ merge(Compressor.prototype, { return arg || make_node(AST_Undefined, iife); }, visit); }); - if (fn.rest) scan_declaration(tw, compressor, fn.rest, compressor.option("rests") && function() { - return make_node(AST_Array, fn, { + var rest = fn.rest; + if (rest) scan_declaration(tw, compressor, rest, compressor.option("rests") && function() { + return fn.rest === rest ? make_node(AST_Array, fn, { elements: iife.args.slice(fn.argnames.length), - }); + }) : rest; }, visit); walk_lambda(fn, tw); var safe_ids = tw.safe_ids; diff --git a/lib/parse.js b/lib/parse.js index c6d7cb6f..04b40149 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -1198,6 +1198,7 @@ function parse($TEXT, options) { } } else { body = []; + handle_regexp(); value = maybe_assign(); } S.input.pop_directives_stack(); diff --git a/test/compress/arrows.js b/test/compress/arrows.js index fbb18b95..e7322b72 100644 --- a/test/compress/arrows.js +++ b/test/compress/arrows.js @@ -694,3 +694,12 @@ issue_4476: { expect_stdout: "foo bar" node_version: ">=4" } + +issue_4666: { + input: { + console.log((a => /[0-9]/.test(a))(42)); + } + expect_exact: "console.log((a=>/[0-9]/.test(a))(42));" + expect_stdout: "true" + node_version: ">=4" +} diff --git a/test/compress/rests.js b/test/compress/rests.js index 676b5e7f..bbbcc14b 100644 --- a/test/compress/rests.js +++ b/test/compress/rests.js @@ -757,3 +757,30 @@ issue_4644_2: { expect_stdout: "PASS 0 undefined" node_version: ">=6" } + +issue_4666: { + options = { + evaluate: true, + reduce_vars: true, + rests: true, + toplevel: true, + unsafe: true, + unused: true, + } + input: { + var a = 0, b = 0; + var o = ((...c) => a++ + c)(b); + for (var k in o) + b++; + console.log(a, b); + } + expect: { + var a = 0, b = 0; + var o = (c => +a + c)([ b ]); + for(var k in o) + b++; + console.log(1, b); + } + expect_stdout: "1 2" + node_version: ">=6" +} |