[Pkg-javascript-commits] [uglifyjs] 339/491: fix escape analysis on `||` and `&&` (#2600)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:51:50 UTC 2018


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.

commit db902af4c6e7a8c7e7a690591a0cd6a0d611300f
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Fri Dec 15 19:48:14 2017 +0800

    fix escape analysis on `||` and `&&` (#2600)
    
    fixes #2598
---
 lib/compress.js              |  1 +
 test/compress/reduce_vars.js | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/lib/compress.js b/lib/compress.js
index a8bcf54..0fac325 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 394bb58..bf1155b 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"
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list