aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-03 00:54:41 +0800
committerGitHub <noreply@github.com>2017-03-03 00:54:41 +0800
commitb49e142a26094ccb0a6e9f597e7363ba02280eb4 (patch)
treee650bd473afb447589c402673303d92b443d7c5e
parentee3b39b909c279a0115c7562cab2c9b37fb37c21 (diff)
downloadtracifyjs-b49e142a26094ccb0a6e9f597e7363ba02280eb4.tar.gz
tracifyjs-b49e142a26094ccb0a6e9f597e7363ba02280eb4.zip
disable do{...}while(false) optimisation (#1534)
- fails to handle `break` in body fixes #1532
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/loops.js26
2 files changed, 26 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 99235987..01fdeeae 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 ca05461c..e26dc79f 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);
+ }
}
}