fix #2994 by fixing block aborts() definition

This commit is contained in:
Fábio Santos 2018-03-14 18:46:26 +00:00
parent 569757d14d
commit 703a5b1fda
2 changed files with 45 additions and 2 deletions

View File

@ -3074,8 +3074,12 @@ merge(Compressor.prototype, {
def(AST_Statement, return_null); def(AST_Statement, return_null);
def(AST_Jump, return_this); def(AST_Jump, return_this);
function block_aborts(){ function block_aborts(){
var n = this.body.length; for (var i = 0; i < this.body.length; i++) {
return n > 0 && aborts(this.body[n - 1]); if (aborts(this.body[i])) {
return this.body[i];
}
}
return null;
}; };
def(AST_Import, function(){ return null; }); def(AST_Import, function(){ return null; });
def(AST_BlockStatement, block_aborts); def(AST_BlockStatement, block_aborts);

View File

@ -1204,6 +1204,45 @@ issue_2560: {
] ]
} }
issue_2994: {
options = {
conditionals: true,
if_return: true
}
input: {
function f() {
if (condition1) {
if (condition2) {
return aValue;
} else {
const variable1 = 'something';
if (condition3) {
const variable2 = 'else';
return anotherValue;
} else {
return undefined;
}
}
}
}
}
expect: {
function f() {
if (condition1) {
if (condition2) return aValue;
{
const variable1 = 'something';
if (condition3) {
const variable2 = 'else';
return anotherValue;
}
return;
}
}
}
}
}
hoist_decl: { hoist_decl: {
options = { options = {
conditionals: true, conditionals: true,