@@ -2530,7 +2530,7 @@ Compressor.prototype.compress = function(node) {
2530
2530
}
2531
2531
if (names.has(sym.name)) continue;
2532
2532
names.set(sym.name, true);
2533
- if (value) arg = !arg || is_undefined(arg) ? value : null;
2533
+ if (value) arg = is_undefined(arg) ? value : null;
2534
2534
if (!arg && !value) {
2535
2535
arg = make_node(AST_Undefined, sym).transform(compressor);
2536
2536
} else if (arg instanceof AST_Lambda && arg.pinned()) {
@@ -3423,18 +3423,14 @@ Compressor.prototype.compress = function(node) {
3423
3423
return false;
3424
3424
}
3425
3425
3426
- function is_return_void(value) {
3427
- return !value || value instanceof AST_UnaryPrefix && value.operator == "void";
3428
- }
3429
-
3430
3426
function match_target(target) {
3431
3427
return last_of(compressor, function(node) {
3432
3428
return node === target;
3433
3429
});
3434
3430
}
3435
3431
3436
3432
function can_drop_abort(ab) {
3437
- if (ab instanceof AST_Return) return in_lambda && is_return_void (ab.value);
3433
+ if (ab instanceof AST_Return) return in_lambda && is_undefined (ab.value);
3438
3434
if (!(ab instanceof AST_LoopControl)) return false;
3439
3435
var lct = compressor.loopcontrol_target(ab);
3440
3436
if (ab instanceof AST_Continue) return match_target(loop_body(lct));
@@ -3481,9 +3477,7 @@ Compressor.prototype.compress = function(node) {
3481
3477
block = last.body;
3482
3478
}
3483
3479
block.pop();
3484
- if (ab.value) block.push(make_node(AST_SimpleStatement, ab.value, {
3485
- body: ab.value.expression
3486
- }));
3480
+ if (ab.value) block.push(make_node(AST_SimpleStatement, ab.value, { body: ab.value }));
3487
3481
return body;
3488
3482
}
3489
3483
@@ -4000,7 +3994,8 @@ Compressor.prototype.compress = function(node) {
4000
3994
}
4001
3995
4002
3996
function is_undefined(node, compressor) {
4003
- return node.is_undefined
3997
+ return node == null
3998
+ || node.is_undefined
4004
3999
|| node instanceof AST_Undefined
4005
4000
|| node instanceof AST_UnaryPrefix
4006
4001
&& node.operator == "void"
@@ -9915,7 +9910,7 @@ Compressor.prototype.compress = function(node) {
9915
9910
if (argname instanceof AST_DefaultValue) {
9916
9911
if (!has_default) has_default = 1;
9917
9912
var arg = has_default == 1 && self.args[index];
9918
- if (arg && !is_undefined(arg)) has_default = 2;
9913
+ if (!is_undefined(arg)) has_default = 2;
9919
9914
if (has_arg_refs(fn, argname.value)) return false;
9920
9915
argname = argname.name;
9921
9916
}
@@ -13176,7 +13171,6 @@ Compressor.prototype.compress = function(node) {
13176
13171
if (!no_return) {
13177
13172
if (async) scan_local_returns(inlined, function(node) {
13178
13173
var value = node.value;
13179
- if (!value) return;
13180
13174
if (is_undefined(value)) return;
13181
13175
node.value = make_node(AST_Await, call, { expression: value });
13182
13176
});
@@ -13320,10 +13314,7 @@ Compressor.prototype.compress = function(node) {
13320
13314
if (!no_return) scan_local_returns(inlined, function(node) {
13321
13315
node.in_bool = false;
13322
13316
var value = node.value;
13323
- if (op == "void") {
13324
- if (!value) return;
13325
- if (is_undefined(value)) return;
13326
- }
13317
+ if (op == "void" && is_undefined(value)) return;
13327
13318
node.value = make_node(AST_UnaryPrefix, self, {
13328
13319
operator: op,
13329
13320
expression: value || make_node(AST_Undefined, node).transform(compressor),
@@ -13371,8 +13362,7 @@ Compressor.prototype.compress = function(node) {
13371
13362
13372
13363
OPT(AST_Return, function(self, compressor) {
13373
13364
var value = self.value;
13374
- if (compressor.option("side_effects")
13375
- && value
13365
+ if (value && compressor.option("side_effects")
13376
13366
&& is_undefined(value, compressor)
13377
13367
&& !in_async_generator(compressor.find_parent(AST_Scope))) {
13378
13368
self.value = null;
0 commit comments