fix corner case in functions & inline (#5767)

fixes #5766
This commit is contained in:
Alex Lam S.L
2022-12-27 08:59:16 +08:00
committed by GitHub
parent f2b6f1def0
commit c9117041fa
3 changed files with 84 additions and 3 deletions

View File

@@ -7498,6 +7498,7 @@ Compressor.prototype.compress = function(node) {
});
body.push(defun);
if (value !== fn) [].push.apply(side_effects, value.expressions.slice(0, -1));
sym.eliminated++;
} else {
if (drop_sym
&& var_defs[sym.id] > 1
@@ -14065,8 +14066,12 @@ Compressor.prototype.compress = function(node) {
def.single_use = false;
if (!in_loop) return;
if (def.references.length == def.replaced) return;
if (def.orig.length == def.eliminated) return;
if (def.orig.length == 1 && fn.functions.has(name)) return;
switch (def.orig.length - def.eliminated) {
case 0:
return;
case 1:
if (fn.functions.has(name)) return;
}
if (!all(def.orig, function(sym) {
if (sym instanceof AST_SymbolConst) return false;
if (sym instanceof AST_SymbolFunarg) return !sym.unused && def.scope.resolve() !== fn;