@@ -3529,15 +3529,15 @@ Compressor.prototype.compress = function(node) {
3529
3529
var declare_only, jump, merge_jump;
3530
3530
var in_iife = in_lambda && parent && parent.TYPE == "Call" && parent.expression === self;
3531
3531
var chain_if_returns = in_lambda && compressor.option("conditionals") && compressor.option("sequences");
3532
+ var drop_return_void = !(in_try && in_try.bfinally && in_async_generator(in_lambda));
3532
3533
var multiple_if_returns = has_multiple_if_returns(statements);
3533
3534
for (var i = statements.length; --i >= 0;) {
3534
3535
var stat = statements[i];
3535
3536
var j = next_index(i);
3536
3537
var next = statements[j];
3537
3538
3538
3539
if (in_lambda && declare_only && !next && stat instanceof AST_Return
3539
- && !(self instanceof AST_SwitchBranch)
3540
- && !(in_try && in_try.bfinally && in_async_generator(in_lambda))) {
3540
+ && drop_return_void && !(self instanceof AST_SwitchBranch)) {
3541
3541
var body = stat.value;
3542
3542
if (!body) {
3543
3543
changed = true;
@@ -3633,7 +3633,7 @@ Compressor.prototype.compress = function(node) {
3633
3633
var in_bool = stat.body.in_bool || next instanceof AST_Return && next.in_bool;
3634
3634
// if (foo()) return x; return y; ---> return foo() ? x : y;
3635
3635
if (!stat.alternative && next instanceof AST_Return
3636
- && (!value == !next.value || !in_async_generator(in_lambda) )) {
3636
+ && (drop_return_void || !value == !next.value)) {
3637
3637
changed = true;
3638
3638
stat = stat.clone();
3639
3639
stat.alternative = make_node(AST_BlockStatement, next, {
@@ -9686,7 +9686,7 @@ Compressor.prototype.compress = function(node) {
9686
9686
self.body,
9687
9687
],
9688
9688
}).optimize(compressor);
9689
- if (cons_value && alt_value || !in_async_generator(compressor.find_parent(AST_Scope) )) {
9689
+ if (cons_value && alt_value || !keep_return_void( )) {
9690
9690
var exit = make_node(self.body.CTOR, self, {
9691
9691
value: make_node(AST_Conditional, self, {
9692
9692
condition: self.condition,
@@ -9762,6 +9762,22 @@ Compressor.prototype.compress = function(node) {
9762
9762
return node instanceof AST_BlockStatement ? node.body : [ node ];
9763
9763
}
9764
9764
9765
+ function keep_return_void() {
9766
+ var has_finally = false, level = 0, node = compressor.self();
9767
+ do {
9768
+ if (node instanceof AST_Catch) {
9769
+ if (compressor.parent(level).bfinally) has_finally = true;
9770
+ level++;
9771
+ } else if (node instanceof AST_Finally) {
9772
+ level++;
9773
+ } else if (node instanceof AST_Scope) {
9774
+ return has_finally && in_async_generator(node);
9775
+ } else if (node instanceof AST_Try) {
9776
+ if (node.bfinally) has_finally = true;
9777
+ }
9778
+ } while (node = compressor.parent(level++));
9779
+ }
9780
+
9765
9781
function last_index(stats) {
9766
9782
for (var index = stats.length; --index >= 0;) {
9767
9783
if (!is_declaration(stats[index], true)) break;
0 commit comments