@@ -9958,9 +9958,12 @@ Compressor.prototype.compress = function(node) {
|
||||
}) : arg);
|
||||
}
|
||||
|
||||
function avoid_await_yield(parent_scope) {
|
||||
function avoid_await_yield(compressor, parent_scope) {
|
||||
if (!parent_scope) parent_scope = compressor.find_parent(AST_Scope);
|
||||
var avoid = [];
|
||||
if (is_async(parent_scope)) avoid.push("await");
|
||||
if (is_async(parent_scope) || parent_scope instanceof AST_Toplevel && compressor.option("module")) {
|
||||
avoid.push("await");
|
||||
}
|
||||
if (is_generator(parent_scope)) avoid.push("yield");
|
||||
return avoid.length && makePredicate(avoid);
|
||||
}
|
||||
@@ -10322,7 +10325,7 @@ Compressor.prototype.compress = function(node) {
|
||||
if (exp === fn
|
||||
&& !fn.name
|
||||
&& (!value || value.is_constant_expression())
|
||||
&& safe_from_await_yield(fn, avoid_await_yield(compressor.find_parent(AST_Scope)))) {
|
||||
&& safe_from_await_yield(fn, avoid_await_yield(compressor))) {
|
||||
return make_sequence(self, convert_args(value)).optimize(compressor);
|
||||
}
|
||||
}
|
||||
@@ -10400,7 +10403,7 @@ Compressor.prototype.compress = function(node) {
|
||||
&& all(fn.body, is_empty)
|
||||
&& (fn === exp ? fn_name_unused(fn, compressor) : !has_default && !has_destructured && !fn.rest)
|
||||
&& !(is_arrow(fn) && fn.value)
|
||||
&& safe_from_await_yield(fn, avoid_await_yield(compressor.find_parent(AST_Scope)))) {
|
||||
&& safe_from_await_yield(fn, avoid_await_yield(compressor))) {
|
||||
return make_sequence(self, convert_args()).optimize(compressor);
|
||||
}
|
||||
}
|
||||
@@ -10559,7 +10562,7 @@ Compressor.prototype.compress = function(node) {
|
||||
})) return;
|
||||
var scope = compressor.find_parent(AST_Scope);
|
||||
var abort = false;
|
||||
var avoid = avoid_await_yield(scope);
|
||||
var avoid = avoid_await_yield(compressor, scope);
|
||||
var begin;
|
||||
var in_order = [];
|
||||
var side_effects = false;
|
||||
@@ -10674,7 +10677,7 @@ Compressor.prototype.compress = function(node) {
|
||||
} while (!(scope instanceof AST_Scope));
|
||||
insert = scope.body.indexOf(child) + 1;
|
||||
if (!insert) return false;
|
||||
if (!safe_from_await_yield(fn, avoid_await_yield(scope))) return false;
|
||||
if (!safe_from_await_yield(fn, avoid_await_yield(compressor, scope))) return false;
|
||||
var safe_to_inject = (exp !== fn || fn.parent_scope.resolve() === scope) && !scope.pinned();
|
||||
if (scope instanceof AST_Toplevel) {
|
||||
if (compressor.toplevel.vars) {
|
||||
@@ -13074,7 +13077,7 @@ Compressor.prototype.compress = function(node) {
|
||||
var arrow = !(value.uses_arguments || is_generator(value) || value.contains_this());
|
||||
if (arrow) {
|
||||
if (!scope) scope = compressor.find_parent(AST_Scope);
|
||||
var avoid = avoid_await_yield(scope);
|
||||
var avoid = avoid_await_yield(compressor, scope);
|
||||
value.each_argname(function(argname) {
|
||||
if (avoid[argname.name]) arrow = false;
|
||||
});
|
||||
@@ -13491,7 +13494,7 @@ Compressor.prototype.compress = function(node) {
|
||||
}));
|
||||
return !abort;
|
||||
})) return;
|
||||
if (!safe_from_await_yield(fn, avoid_await_yield(scope))) return;
|
||||
if (!safe_from_await_yield(fn, avoid_await_yield(compressor, scope))) return;
|
||||
fn.functions.each(function(def, name) {
|
||||
scope.functions.set(name, def);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user