fix corner case in reduce_vars (#4203)

fixes #4198
This commit is contained in:
Alex Lam S.L
2020-10-12 12:02:44 +01:00
committed by GitHub
parent b512726cf3
commit 1cdf810f0b
2 changed files with 42 additions and 1 deletions

View File

@@ -6640,7 +6640,13 @@ merge(Compressor.prototype, {
if (def.scope === scope) return true;
return !scope.variables.has(node.name) && !scope.globals.has(node.name);
}
return def.scope === scope || !scope.find_variable(node);
if (def.scope === scope) return true;
var s = def.scope;
do {
s = s.parent_scope;
if (s.variables.has(node.name)) return false;
} while (s !== scope);
return true;
}) ? make_node(AST_Var, self, {
definitions: self.definitions.map(function(defn) {
var name = make_node(AST_SymbolVar, defn.name, defn.name);