[Pkg-javascript-commits] [uglifyjs] 62/228: disable do{...}while(false) optimisation (#1534)

Jonas Smedegaard dr at jones.dk
Sat Apr 15 14:25:17 UTC 2017


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

js pushed a commit to branch master
in repository uglifyjs.

commit b49e142a26094ccb0a6e9f597e7363ba02280eb4
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Fri Mar 3 00:54:41 2017 +0800

    disable do{...}while(false) optimisation (#1534)
    
    - fails to handle `break` in body
    
    fixes #1532
---
 lib/compress.js        |  2 +-
 test/compress/loops.js | 26 +++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/lib/compress.js b/lib/compress.js
index 9923598..01fdeea 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -2132,7 +2132,7 @@ merge(Compressor.prototype, {
                 }
             } else {
                 // self instanceof AST_Do
-                return self.body;
+                return self;
             }
         }
         if (self instanceof AST_While) {
diff --git a/test/compress/loops.js b/test/compress/loops.js
index ca05461..e26dc79 100644
--- a/test/compress/loops.js
+++ b/test/compress/loops.js
@@ -213,6 +213,30 @@ evaluate: {
             a();
         for(;;)
             c();
-        d();
+        // rule disabled due to issue_1532
+        do d(); while (false);
+    }
+}
+
+issue_1532: {
+    options = {
+        evaluate: true,
+        loops: true,
+    }
+    input: {
+        function f(x, y) {
+            do {
+                if (x) break;
+                foo();
+            } while (false);
+        }
+    }
+    expect: {
+        function f(x, y) {
+            do {
+                if (x) break;
+                foo();
+            } while (false);
+        }
     }
 }

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