fix dead_code on for (#2552)
This commit is contained in:
@@ -3128,9 +3128,6 @@ merge(Compressor.prototype, {
|
|||||||
if (!cond) {
|
if (!cond) {
|
||||||
var body = [];
|
var body = [];
|
||||||
extract_declarations_from_unreachable_code(compressor, self.body, 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) {
|
if (self.init instanceof AST_Statement) {
|
||||||
body.push(self.init);
|
body.push(self.init);
|
||||||
} else if (self.init) {
|
} else if (self.init) {
|
||||||
@@ -3138,6 +3135,9 @@ merge(Compressor.prototype, {
|
|||||||
body: self.init
|
body: self.init
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
body.push(make_node(AST_SimpleStatement, self.condition, {
|
||||||
|
body: self.condition
|
||||||
|
}));
|
||||||
return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
|
return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -468,3 +468,27 @@ init_side_effects: {
|
|||||||
}
|
}
|
||||||
expect_stdout: true
|
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"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user