simplify do-while into for (#2907)

fixes #2904
This commit is contained in:
Alex Lam S.L
2018-02-12 23:28:28 +08:00
committed by GitHub
parent 2088e1c19d
commit 0809699bdc
3 changed files with 27 additions and 9 deletions

View File

@@ -3672,6 +3672,13 @@ merge(Compressor.prototype, {
]
}).optimize(compressor);
}
if (self.body instanceof AST_SimpleStatement) return make_node(AST_For, self, {
condition: make_sequence(self.condition, [
self.body.body,
self.condition
]),
body: make_node(AST_EmptyStatement, self)
}).optimize(compressor);
return self;
});