diff --git a/lib/compress.js b/lib/compress.js index c1388b75..62f63a96 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -363,7 +363,7 @@ merge(Compressor.prototype, { safe_ids = save_ids; return true; } - if (node instanceof AST_Function) { + if (node instanceof AST_Function || node instanceof AST_Arrow) { push(); var iife; if (!node.name diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 430e3797..c185b717 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -2537,3 +2537,53 @@ accessor: { } expect_stdout: "1 1" } + +issue_2090_1: { + options = { + evaluate: true, + reduce_vars: true, + } + input: { + console.log(function() { + var x = 1; + [].forEach(() => x = 2); + return x; + }()); + } + expect: { + console.log(function() { + var x = 1; + [].forEach(() => x = 2); + return x; + }()); + } + expect_stdout: "1" + node_version: ">=4" +} + +issue_2090_2: { + options = { + evaluate: true, + reduce_vars: true, + } + input: { + console.log(function() { + var x = 1; + [].forEach(() => { + x = 2; + }); + return x; + }()); + } + expect: { + console.log(function() { + var x = 1; + [].forEach(() => { + x = 2; + }); + return x; + }()); + } + expect_stdout: "1" + node_version: ">=4" +}