fix corner case in functions (#5037)

fixes #5036
This commit is contained in:
Alex Lam S.L
2021-06-24 20:43:52 +01:00
committed by GitHub
parent 1a064b6e74
commit 7621527a5f
2 changed files with 28 additions and 5 deletions

View File

@@ -6574,12 +6574,10 @@ merge(Compressor.prototype, {
return all(def.references, function(ref) {
var scope = ref.scope;
if (scope.find_variable(name) !== sym) return false;
if (forbidden) {
if (forbidden) do {
scope = scope.resolve();
do {
if (forbidden(scope)) return false;
} while ((scope = scope.parent_scope.resolve()) && scope !== fn);
}
if (forbidden(scope)) return false;
} while (scope !== fn && (scope = scope.parent_scope));
return true;
}) && def;
}