@@ -1211,10 +1211,19 @@ merge(Compressor.prototype, {
|
|||||||
var stat = statements[i];
|
var stat = statements[i];
|
||||||
var next = statements[i + 1];
|
var next = statements[i + 1];
|
||||||
|
|
||||||
if (in_lambda && stat instanceof AST_Return && !stat.value && !next) {
|
if (in_lambda && !next && stat instanceof AST_Return) {
|
||||||
CHANGED = true;
|
if (!stat.value) {
|
||||||
statements.length--;
|
CHANGED = true;
|
||||||
continue;
|
statements.length--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (stat.value instanceof AST_UnaryPrefix && stat.value.operator == "void") {
|
||||||
|
CHANGED = true;
|
||||||
|
statements[i] = make_node(AST_SimpleStatement, stat, {
|
||||||
|
body: stat.value.expression
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat instanceof AST_If) {
|
if (stat instanceof AST_If) {
|
||||||
@@ -1301,9 +1310,16 @@ merge(Compressor.prototype, {
|
|||||||
&& prev instanceof AST_If && prev.body instanceof AST_Return
|
&& prev instanceof AST_If && prev.body instanceof AST_Return
|
||||||
&& i + 2 == statements.length && next instanceof AST_SimpleStatement) {
|
&& i + 2 == statements.length && next instanceof AST_SimpleStatement) {
|
||||||
CHANGED = true;
|
CHANGED = true;
|
||||||
statements.push(make_node(AST_Return, next, {
|
stat = stat.clone();
|
||||||
value: null
|
stat.alternative = make_node(AST_BlockStatement, next, {
|
||||||
}).transform(compressor));
|
body: [
|
||||||
|
next,
|
||||||
|
make_node(AST_Return, next, {
|
||||||
|
value: null
|
||||||
|
})
|
||||||
|
]
|
||||||
|
});
|
||||||
|
statements.splice(i, 2, stat.transform(compressor));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,3 +122,25 @@ return_undefined: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return_void: {
|
||||||
|
options = {
|
||||||
|
if_return: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
function g() {
|
||||||
|
h();
|
||||||
|
}
|
||||||
|
return g();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f() {
|
||||||
|
h();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user