fix if_return on block-scoped variables (#2021)

fixes #1317
This commit is contained in:
Alex Lam S.L
2017-05-29 18:08:08 +08:00
committed by GitHub
parent ee23a84e14
commit c2e471e3ad
2 changed files with 61 additions and 1 deletions

View File

@@ -1068,7 +1068,9 @@ merge(Compressor.prototype, {
}
function can_merge_flow(ab) {
if (!ab) return false;
if (!ab || !all(ret, function(stat) {
return !(stat instanceof AST_Const || stat instanceof AST_Let);
})) return false;
var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab) : null;
return ab instanceof AST_Return && in_lambda && is_return_void(ab.value)
|| ab instanceof AST_Continue && self === loop_body(lct)