fix corner cases in inline (#5375)

This commit is contained in:
Alex Lam S.L
2022-03-03 20:05:31 +00:00
committed by GitHub
parent 104d385ba9
commit e2b00814a8
3 changed files with 46 additions and 1 deletions

View File

@@ -10524,7 +10524,7 @@ Compressor.prototype.compress = function(node) {
insert = scope.body.indexOf(child) + 1;
if (!insert) return false;
if (!safe_from_await_yield(fn, avoid_await_yield(scope))) return false;
var safe_to_inject = exp !== fn || fn.parent_scope.resolve() === scope;
var safe_to_inject = (exp !== fn || fn.parent_scope.resolve() === scope) && !scope.pinned();
if (scope instanceof AST_Toplevel) {
if (compressor.toplevel.vars) {
defined.set("arguments", true);
@@ -13252,6 +13252,7 @@ Compressor.prototype.compress = function(node) {
if (!(fn instanceof AST_LambdaExpression)) return;
if (fn.name) return;
if (fn.uses_arguments) return;
if (fn.pinned()) return;
if (is_generator(fn)) return;
var arrow = is_arrow(fn);
if (arrow && fn.value) return;
@@ -13267,6 +13268,7 @@ Compressor.prototype.compress = function(node) {
scope = scope.parent_scope;
}
if (!member(scope, compressor.stack)) return;
if (scope.pinned() && fn.variables.size() > (arrow ? 0 : 1)) return;
if (scope instanceof AST_Toplevel) {
if (fn.variables.size() > (arrow ? 0 : 1)) {
if (!compressor.toplevel.vars) return;