fix corner case in collapse_vars (#5390)

fixes #5389
This commit is contained in:
Alex Lam S.L
2022-03-22 05:05:57 +00:00
committed by GitHub
parent a8e040b133
commit c624b43739
3 changed files with 35 additions and 1 deletions

View File

@@ -851,6 +851,9 @@ var AST_DefClass = DEFNODE("DefClass", null, {
$propdoc: {
name: "[AST_SymbolDefClass] the name of this class",
},
resolve: function(def_class) {
return def_class ? this : this.parent_scope.resolve();
},
_validate: function() {
if (!(this.name instanceof AST_SymbolDefClass)) throw new Error("name must be AST_SymbolDefClass");
},

View File

@@ -3269,7 +3269,7 @@ Compressor.prototype.compress = function(node) {
if (def.scope.resolve() !== scope) return true;
if (modify_toplevel && compressor.exposed(def)) return true;
return !all(def.references, function(ref) {
return ref.scope.resolve() === scope;
return ref.scope.resolve(true) === scope;
});
}