}
var drop_body = false;
if (compressor.option("arrows") && is_arrow(exp)) {
- if (exp.value) {
- exp.value = exp.value.drop_side_effect_free(compressor);
- } else {
+ if (!exp.value) {
drop_body = true;
+ } else if (!is_async(exp) || is_primitive(compressor, exp.value)) {
+ exp.value = exp.value.drop_side_effect_free(compressor);
}
} else if (exp instanceof AST_AsyncFunction || exp instanceof AST_Function) {
if (exp.name) {
}
}
if (drop_body) {
+ var async = is_async(exp);
exp.process_expression(false, function(node) {
- var value = node.value && node.value.drop_side_effect_free(compressor, true);
- return value ? make_node(AST_SimpleStatement, node, {
- body: value
- }) : make_node(AST_EmptyStatement, node);
+ var value = node.value;
+ if (value) {
+ if (async && !is_primitive(compressor, value)) return node;
+ value = value.drop_side_effect_free(compressor, true);
+ }
+ if (!value) return make_node(AST_EmptyStatement, node);
+ return make_node(AST_SimpleStatement, node, { body: value });
});
scan_local_returns(exp, function(node) {
- if (node.value) node.value = node.value.drop_side_effect_free(compressor);
+ var value = node.value;
+ if (value) {
+ if (async && !is_primitive(compressor, value)) return;
+ node.value = value.drop_side_effect_free(compressor);
+ }
});
// always shallow clone to ensure stripping of negated IIFEs
self = self.clone();