fix corner case in collapse_vars (#4587)

fixes #4586
This commit is contained in:
Alex Lam S.L
2021-01-23 23:05:43 +00:00
committed by GitHub
parent acc443b2cf
commit ef9f7ca3e7
2 changed files with 47 additions and 0 deletions

View File

@@ -2345,6 +2345,7 @@ merge(Compressor.prototype, {
if (expr.operator == "="
&& lhs instanceof AST_SymbolRef
&& (def = lhs.definition()).references[0] === lhs
&& !(scope.uses_arguments && is_funarg(def))
&& !compressor.exposed(def)) {
var referenced = def.references.length - def.replaced;
if (referenced > 1) mangleable_var(expr.right);
@@ -2357,6 +2358,7 @@ merge(Compressor.prototype, {
var def = expr.name.definition();
if (def.const_redefs) return;
if (!member(expr.name, def.orig)) return;
if (scope.uses_arguments && is_funarg(def)) return;
var declared = def.orig.length - def.eliminated - (declare_only[def.name] || 0);
var referenced = def.references.length - def.replaced - (assignments[def.name] || 0);
if (declared > 1 && !(expr.name instanceof AST_SymbolFunarg)) {