[Pkg-javascript-commits] [uglifyjs] 426/491: avoid double counting within single-use functions (#2785)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:52:00 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 cbbe6fad60dd073c63575f591d631efa94bbceaf
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Mon Jan 15 16:42:15 2018 +0800

    avoid double counting within single-use functions (#2785)
    
    fixes #2783
---
 lib/compress.js            |  1 +
 test/compress/functions.js | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/lib/compress.js b/lib/compress.js
index 321a134..7e3503f 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -5022,6 +5022,7 @@ merge(Compressor.prototype, {
             }
             if (single_use && fixed) {
                 if (fixed instanceof AST_Defun) {
+                    fixed._squeezed = true;
                     fixed = make_node(AST_Function, fixed, fixed);
                 }
                 var value;
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 222aa0c..2d55dd5 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -1951,3 +1951,41 @@ issue_2737_2: {
     }
     expect_stdout: "PASS"
 }
+
+issue_2783: {
+    options = {
+        collapse_vars: true,
+        conditionals: true,
+        if_return: true,
+        inline: true,
+        reduce_vars: true,
+        unused: true,
+    }
+    input: {
+        (function() {
+            return g;
+            function f(a) {
+                var b = a.b;
+                if (b) return b;
+                return a;
+            }
+            function g(o, i) {
+                while (i--) {
+                    console.log(f(o));
+                }
+            }
+        })()({ b: "PASS" }, 1);
+    }
+    expect: {
+        (function() {
+            return function(o,i) {
+                while (i--) console.log(f(o));
+            };
+            function f(a) {
+                var b = a.b;
+                return b || a;
+            }
+        })()({ b: "PASS" },1);
+    }
+    expect_stdout: "PASS"
+}

-- 
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