@@ -2423,17 +2423,18 @@ merge(Compressor.prototype, {
|
|||||||
// We fix it at this stage by moving the `var` outside the `for`.
|
// We fix it at this stage by moving the `var` outside the `for`.
|
||||||
if (node instanceof AST_For) {
|
if (node instanceof AST_For) {
|
||||||
descend(node, this);
|
descend(node, this);
|
||||||
|
var block;
|
||||||
if (node.init instanceof AST_BlockStatement) {
|
if (node.init instanceof AST_BlockStatement) {
|
||||||
var block = node.init;
|
block = node.init;
|
||||||
node.init = block.body.pop();
|
node.init = block.body.pop();
|
||||||
block.body.push(node);
|
block.body.push(node);
|
||||||
return in_list ? MAP.splice(block.body) : block;
|
}
|
||||||
} else if (node.init instanceof AST_SimpleStatement) {
|
if (node.init instanceof AST_SimpleStatement) {
|
||||||
node.init = node.init.body;
|
node.init = node.init.body;
|
||||||
} else if (is_empty(node.init)) {
|
} else if (is_empty(node.init)) {
|
||||||
node.init = null;
|
node.init = null;
|
||||||
}
|
}
|
||||||
return node;
|
return !block ? node : in_list ? MAP.splice(block.body) : block;
|
||||||
}
|
}
|
||||||
if (node instanceof AST_LabeledStatement && node.body instanceof AST_For) {
|
if (node instanceof AST_LabeledStatement && node.body instanceof AST_For) {
|
||||||
descend(node, this);
|
descend(node, this);
|
||||||
|
|||||||
@@ -1239,3 +1239,25 @@ issue_2226_3: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "3"
|
expect_stdout: "3"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_2288: {
|
||||||
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
beautify = {
|
||||||
|
beautify: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function foo(o) {
|
||||||
|
for (var j = o.a, i = 0; i < 0; i++);
|
||||||
|
for (var i = 0; i < 0; i++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function foo(o) {
|
||||||
|
o.a;
|
||||||
|
for (i = 0; i < 0; i++);
|
||||||
|
for (var i = 0; i < 0; i++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user