fix a corner case in #1530 (#1552)

This commit is contained in:
Alex Lam S.L
2017-03-05 12:12:59 +08:00
committed by GitHub
parent ea9ab9fb0e
commit 78d1bb92d4
2 changed files with 23 additions and 4 deletions

View File

@@ -2760,10 +2760,12 @@ merge(Compressor.prototype, {
}
}
if (exp instanceof AST_Function) {
if (exp.body[0] instanceof AST_Return
&& exp.body[0].value.is_constant()) {
var args = self.args.concat(exp.body[0].value);
return AST_Seq.from_array(args).transform(compressor);
if (exp.body[0] instanceof AST_Return) {
var value = exp.body[0].value;
if (!value || value.is_constant()) {
var args = self.args.concat(value || make_node(AST_Undefined, self));
return AST_Seq.from_array(args).transform(compressor);
}
}
if (compressor.option("side_effects")) {
if (!AST_Block.prototype.has_side_effects.call(exp, compressor)) {