fix dead_code on for (#2552)

This commit is contained in:
Alex Lam S.L
2017-12-02 15:46:05 +08:00
committed by GitHub
parent 85c56adbd1
commit 77332a0315
2 changed files with 27 additions and 3 deletions

View File

@@ -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);
}
}