fix corner case in if_return (#5689)

fixes #5688
This commit is contained in:
Alex Lam S.L
2022-09-29 23:49:51 +01:00
committed by GitHub
parent e1e3516397
commit 6cdc035b2f
3 changed files with 56 additions and 4 deletions

View File

@@ -3745,14 +3745,17 @@ Compressor.prototype.compress = function(node) {
return true;
}
if (!(ab instanceof AST_LoopControl)) return false;
if (jump && self instanceof AST_SwitchBranch) {
if (self instanceof AST_SwitchBranch) {
if (jump instanceof AST_Exit) {
if (!in_lambda) return false;
if (jump.value) return false;
} else if (compressor.loopcontrol_target(jump) !== parent) {
merge_jump = true;
} else if (jump) {
if (compressor.loopcontrol_target(jump) !== parent) return false;
merge_jump = true;
} else if (jump === false) {
return false;
}
merge_jump = true;
}
var lct = compressor.loopcontrol_target(ab);
if (ab instanceof AST_Continue) return match_target(loop_body(lct));
@@ -3789,7 +3792,7 @@ Compressor.prototype.compress = function(node) {
end = statements.lastIndexOf(stop);
} else {
stop = statements[end];
if (stop !== jump) jump = null;
if (stop !== jump) jump = false;
}
var tail = statements.splice(start, end - start).filter(function(stat) {
if (stat instanceof AST_LambdaDefinition) {