improve if_return (#2727)

This commit is contained in:
Alex Lam S.L
2018-01-05 20:24:30 +08:00
committed by GitHub
parent 7f2a591c7e
commit b82feb9302
2 changed files with 27 additions and 2 deletions

View File

@@ -1436,8 +1436,9 @@ merge(Compressor.prototype, {
}
//---
// if (foo()) return x; [ return ; ] ==> return foo() ? x : undefined;
if (multiple_if_returns && in_lambda && value && !stat.alternative
&& (!next || next instanceof AST_Return)) {
if (value && !stat.alternative
&& (!next && in_lambda && multiple_if_returns
|| next instanceof AST_Return)) {
CHANGED = true;
stat = stat.clone();
stat.alternative = next || make_node(AST_Return, stat, {