fix corner case in inline (#5664)

fixes #5662
This commit is contained in:
Alex Lam S.L
2022-09-17 01:54:54 +01:00
committed by GitHub
parent e0b302d651
commit 001f6f9719
3 changed files with 44 additions and 8 deletions

View File

@@ -6278,21 +6278,24 @@ Compressor.prototype.compress = function(node) {
var call = stat.value;
if (!call || call.TYPE != "Call") break;
if (call.is_expr_pure(compressor)) break;
var fn = call.expression;
if (fn instanceof AST_SymbolRef) {
if (self.name && self.name.definition() === fn.definition()) break;
fn = fn.fixed_value();
var exp = call.expression, fn;
if (!(exp instanceof AST_SymbolRef)) {
fn = exp;
} else if (self.name && self.name.definition() === exp.definition()) {
break;
} else {
fn = exp.fixed_value();
}
if (!(fn instanceof AST_Defun || fn instanceof AST_Function)) break;
if (fn.rest) break;
if (fn.uses_arguments) break;
if (fn === call.expression) {
if (fn === exp) {
if (fn.parent_scope !== self) break;
if (!all(fn.enclosed, function(def) {
return def.scope !== self;
})) break;
}
if (fn.name
if ((fn !== exp || fn.name)
&& (parent instanceof AST_ClassMethod || parent instanceof AST_ObjectMethod)
&& parent.value === compressor.self()) break;
if (fn.contains_this()) break;
@@ -6321,7 +6324,7 @@ Compressor.prototype.compress = function(node) {
fn.argnames.push(fn.make_var(AST_SymbolFunarg, fn, "argument_" + len));
} while (++len < self.argnames.length);
}
return call.expression;
return exp;
}
break;
}