gate various label-related transformations (#3812)

This commit is contained in:
Alex Lam S.L
2020-04-22 22:27:26 +01:00
committed by GitHub
parent 01b13d797c
commit 3ae24329eb
4 changed files with 17 additions and 2 deletions

View File

@@ -3962,11 +3962,12 @@ merge(Compressor.prototype, {
});
OPT(AST_LabeledStatement, function(self, compressor) {
if (self.body instanceof AST_Break
if (compressor.option("dead_code")
&& self.body instanceof AST_Break
&& compressor.loopcontrol_target(self.body) === self.body) {
return make_node(AST_EmptyStatement, self);
}
return self.label.references.length == 0 ? self.body : self;
return compressor.option("unused") && self.label.references.length == 0 ? self.body : self;
});
OPT(AST_Block, function(self, compressor) {