collapse_vars: do not replace a constant in loop condition or init (#1562)
This commit is contained in:
@@ -535,10 +535,13 @@ merge(Compressor.prototype, {
|
||||
// Constant single use vars can be replaced in any scope.
|
||||
if (var_decl.value.is_constant()) {
|
||||
var ctt = new TreeTransformer(function(node) {
|
||||
if (node === ref
|
||||
&& !ctt.find_parent(AST_ForIn)) {
|
||||
return replace_var(node, ctt.parent(), true);
|
||||
var parent = ctt.parent();
|
||||
if (parent instanceof AST_IterationStatement
|
||||
&& (parent.condition === node || parent.init === node)) {
|
||||
return node;
|
||||
}
|
||||
if (node === ref)
|
||||
return replace_var(node, parent, true);
|
||||
});
|
||||
stat.transform(ctt);
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user