[Pkg-javascript-commits] [uglifyjs] 337/491: fix `reduce_vars` on `do...while` (#2596)

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 092d9affb829768e652f14c82080e27893e1f022
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Fri Dec 15 16:33:19 2017 +0800

    fix `reduce_vars` on `do...while` (#2596)
---
 lib/compress.js              | 12 +++++++++++-
 test/compress/reduce_vars.js | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/lib/compress.js b/lib/compress.js
index aaadcd1..0162fa4 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -479,7 +479,17 @@ merge(Compressor.prototype, {
                     }
                     return true;
                 }
-                if (node instanceof AST_DWLoop) {
+                if (node instanceof AST_Do) {
+                    var saved_loop = in_loop;
+                    in_loop = node;
+                    push();
+                    node.body.walk(tw);
+                    node.condition.walk(tw);
+                    pop();
+                    in_loop = saved_loop;
+                    return true;
+                }
+                if (node instanceof AST_While) {
                     var saved_loop = in_loop;
                     in_loop = node;
                     push();
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 9ed9c97..394bb58 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -4867,3 +4867,35 @@ defun_single_use_loop: {
         "true",
     ]
 }
+
+do_while: {
+    options = {
+        evaluate: true,
+        reduce_vars: true,
+    }
+    input: {
+        function f(a) {
+            do {
+                (function() {
+                    a && (c = "PASS");
+                })();
+            } while (a = 0);
+        }
+        var c = "FAIL";
+        f(1);
+        console.log(c);
+    }
+    expect: {
+        function f(a) {
+            do {
+                (function() {
+                    a && (c = "PASS");
+                })();
+            } while (a = 0);
+        }
+        var c = "FAIL";
+        f(1);
+        console.log(c);
+    }
+    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