fix label-related bugs (#1835)
- deep cloning of `AST_LabeledStatement`
- `L:do{...}while(false)`
- empty statement with label within block
extend `test/ufuzz.js`
- generate labels for blocks & loops
- generate for-in statements
- skip suspicious option search if `minify()` errs
fixes #1833
This commit is contained in:
@@ -2395,7 +2395,7 @@ merge(Compressor.prototype, {
|
||||
if (compressor.option("dead_code") && self instanceof AST_While) {
|
||||
var a = [];
|
||||
extract_declarations_from_unreachable_code(compressor, self.body, a);
|
||||
return make_node(AST_BlockStatement, self, { body: a });
|
||||
return make_node(AST_BlockStatement, self, { body: a }).optimize(compressor);
|
||||
}
|
||||
if (self instanceof AST_Do) {
|
||||
var has_loop_control = false;
|
||||
@@ -2404,7 +2404,8 @@ merge(Compressor.prototype, {
|
||||
if (node instanceof AST_LoopControl && tw.loopcontrol_target(node) === self)
|
||||
return has_loop_control = true;
|
||||
});
|
||||
self.walk(tw);
|
||||
var parent = compressor.parent();
|
||||
(parent instanceof AST_LabeledStatement ? parent : self).walk(tw);
|
||||
if (!has_loop_control) return self.body;
|
||||
}
|
||||
}
|
||||
@@ -2474,7 +2475,7 @@ merge(Compressor.prototype, {
|
||||
}));
|
||||
}
|
||||
extract_declarations_from_unreachable_code(compressor, self.body, a);
|
||||
return make_node(AST_BlockStatement, self, { body: a });
|
||||
return make_node(AST_BlockStatement, self, { body: a }).optimize(compressor);
|
||||
}
|
||||
if (cond !== self.condition) {
|
||||
cond = make_node_from_constant(cond, self.condition).transform(compressor);
|
||||
@@ -2726,9 +2727,9 @@ merge(Compressor.prototype, {
|
||||
var body = [];
|
||||
if (self.bcatch) extract_declarations_from_unreachable_code(compressor, self.bcatch, body);
|
||||
if (self.bfinally) body = body.concat(self.bfinally.body);
|
||||
return body.length > 0 ? make_node(AST_BlockStatement, self, {
|
||||
return make_node(AST_BlockStatement, self, {
|
||||
body: body
|
||||
}).optimize(compressor) : make_node(AST_EmptyStatement, self);
|
||||
}).optimize(compressor);
|
||||
}
|
||||
return self;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user