@@ -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;
|
||||
});
|
||||
|
||||
|
||||
@@ -605,3 +605,20 @@ issue_2740_5: {
|
||||
}
|
||||
expect_stdout: "0 undefined"
|
||||
}
|
||||
|
||||
issue_2904: {
|
||||
options = {
|
||||
join_vars: true,
|
||||
loops: true,
|
||||
}
|
||||
input: {
|
||||
var a = 1;
|
||||
do {
|
||||
console.log(a);
|
||||
} while (--a);
|
||||
}
|
||||
expect: {
|
||||
for (var a = 1; console.log(a), --a;);
|
||||
}
|
||||
expect_stdout: "1"
|
||||
}
|
||||
|
||||
@@ -1178,9 +1178,7 @@ toplevel_on_loops_1: {
|
||||
console.log("bar:", --x);
|
||||
}
|
||||
var x = 3;
|
||||
do
|
||||
bar();
|
||||
while (x);
|
||||
for (;bar(), x;);
|
||||
}
|
||||
expect_stdout: true
|
||||
}
|
||||
@@ -1208,9 +1206,7 @@ toplevel_off_loops_1: {
|
||||
console.log("bar:", --x);
|
||||
}
|
||||
var x = 3;
|
||||
do
|
||||
bar();
|
||||
while (x);
|
||||
for (;bar(), x;);
|
||||
}
|
||||
expect_stdout: true
|
||||
}
|
||||
@@ -1265,9 +1261,7 @@ toplevel_off_loops_2: {
|
||||
console.log("bar:");
|
||||
}
|
||||
var x = 3;
|
||||
do
|
||||
bar();
|
||||
while (x);
|
||||
for (;bar(), x;);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user