[Pkg-javascript-commits] [uglifyjs] 309/491: fix `dead_code` on `for` (#2552)
Jonas Smedegaard
dr at jones.dk
Wed Feb 14 19:51:47 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 77332a03153285f5e521c99c3b5d796bf5698ef7
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Sat Dec 2 15:46:05 2017 +0800
fix `dead_code` on `for` (#2552)
---
lib/compress.js | 6 +++---
test/compress/loops.js | 24 ++++++++++++++++++++++++
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/lib/compress.js b/lib/compress.js
index 7d87c4a..914fdd0 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3128,9 +3128,6 @@ merge(Compressor.prototype, {
if (!cond) {
var body = [];
extract_declarations_from_unreachable_code(compressor, self.body, body);
- body.push(make_node(AST_SimpleStatement, self.condition, {
- body: self.condition
- }));
if (self.init instanceof AST_Statement) {
body.push(self.init);
} else if (self.init) {
@@ -3138,6 +3135,9 @@ merge(Compressor.prototype, {
body: self.init
}));
}
+ body.push(make_node(AST_SimpleStatement, self.condition, {
+ body: self.condition
+ }));
return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
}
}
diff --git a/test/compress/loops.js b/test/compress/loops.js
index 44e92c5..3538c22 100644
--- a/test/compress/loops.js
+++ b/test/compress/loops.js
@@ -468,3 +468,27 @@ init_side_effects: {
}
expect_stdout: true
}
+
+dead_code_condition: {
+ options = {
+ dead_code: true,
+ evaluate: true,
+ loops: true,
+ sequences: true,
+ }
+ input: {
+ for (var a = 0, b = 5; (a += 1, 3) - 3 && b > 0; b--) {
+ var c = function() {
+ b--;
+ }(a++);
+ }
+ console.log(a);
+ }
+ expect: {
+ var c;
+ var a = 0, b = 5;
+ a += 1, 0,
+ console.log(a);
+ }
+ expect_stdout: "1"
+}
--
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