From: Alex Lam S.L Date: Fri, 15 Dec 2017 11:48:14 +0000 (+0800) Subject: fix escape analysis on `||` and `&&` (#2600) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=db902af4c6e7a8c7e7a690591a0cd6a0d611300f;p=UglifyJS.git fix escape analysis on `||` and `&&` (#2600) fixes #2598 --- diff --git a/lib/compress.js b/lib/compress.js index a8bcf54f..0fac3259 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -674,6 +674,7 @@ merge(Compressor.prototype, { d.escaped = true; return; } else if (parent instanceof AST_Array + || parent instanceof AST_Binary && lazy_op(parent.operator) || parent instanceof AST_Conditional && node !== parent.condition || parent instanceof AST_Sequence && node === parent.tail_node()) { mark_escaped(d, scope, parent, parent, level + 1); diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 394bb586..bf1155b7 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -4899,3 +4899,27 @@ do_while: { } expect_stdout: "PASS" } + +issue_2598: { + options = { + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + function f() {} + function g(a) { + return a || f; + } + console.log(g(false) === g(null)); + } + expect: { + function f() {} + function g(a) { + return a || f; + } + console.log(g(false) === g(null)); + } + expect_stdout: "true" +}