diff --git a/lib/compress.js b/lib/compress.js index 8045cecf..2530ec9f 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1000,11 +1000,7 @@ merge(Compressor.prototype, { arg.walk(tw); if (arg instanceof AST_Spread) iife = false; }); - if (iife) { - exp.reduce_vars = reduce_iife; - } else { - exp.safe_ids = tw.safe_ids; - } + if (iife) exp.reduce_vars = reduce_iife; exp.walk(tw); if (iife) delete exp.reduce_vars; return true; @@ -1299,9 +1295,7 @@ merge(Compressor.prototype, { node.expressions.forEach(function(exp) { exp.walk(tw); }); - tag.safe_ids = tw.safe_ids; tag.walk(tw); - delete tag.reduce_vars; return true; } tag.walk(tw); diff --git a/test/compress/functions.js b/test/compress/functions.js index cad6e5e4..6e75e8fb 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -6285,3 +6285,34 @@ issue_5036: { } expect_stdout: "PASS" } + +issue_5046: { + options = { + conditionals: true, + evaluate: true, + keep_fnames: true, + passes: 2, + reduce_vars: true, + side_effects: true, + toplevel: true, + } + input: { + var a = 0; + if (a) + 0(); + else + (function f() { + f; + return a = "PASS"; + })(); + console.log(a); + } + expect: { + var a = 0; + (a ? 0 : function f() { + return a = "PASS"; + })(); + console.log(a); + } + expect_stdout: "PASS" +}