fix corner case in inline & reduce_vars (#5579)
This commit is contained in:
@@ -8387,9 +8387,8 @@ Compressor.prototype.compress = function(node) {
|
||||
var scopes = [ this ];
|
||||
if (orig instanceof AST_SymbolDeclaration) orig.definition().references.forEach(function(ref) {
|
||||
var s = ref.scope;
|
||||
if (member(s, scopes)) return;
|
||||
do {
|
||||
push_uniq(scopes, s);
|
||||
if (!push_uniq(scopes, s)) return;
|
||||
s = s.parent_scope;
|
||||
} while (s && s !== this);
|
||||
});
|
||||
@@ -12251,12 +12250,19 @@ Compressor.prototype.compress = function(node) {
|
||||
if (fixed instanceof AST_DefClass) fixed = to_class_expr(fixed);
|
||||
if (fixed instanceof AST_LambdaDefinition) fixed = to_func_expr(fixed);
|
||||
if (is_lambda(fixed)) {
|
||||
var scope = self.scope.resolve();
|
||||
var scopes = [];
|
||||
var scope = self.scope;
|
||||
do {
|
||||
scopes.push(scope);
|
||||
if (scope === def.scope) break;
|
||||
} while (scope = scope.parent_scope);
|
||||
fixed.enclosed.forEach(function(def) {
|
||||
if (fixed.variables.has(def.name)) return;
|
||||
if (scope.var_names().has(def.name)) return;
|
||||
scope.enclosed.push(def);
|
||||
scope.var_names().set(def.name, true);
|
||||
for (var i = 0; i < scopes.length; i++) {
|
||||
var scope = scopes[i];
|
||||
if (!push_uniq(scope.enclosed, def)) return;
|
||||
scope.var_names().set(def.name, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
var value;
|
||||
|
||||
@@ -286,7 +286,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
||||
// ensure mangling works if `catch` reuses a scope variable
|
||||
var redef = def.redefined();
|
||||
if (redef) for (var s = node.scope; s; s = s.parent_scope) {
|
||||
push_uniq(s.enclosed, redef);
|
||||
if (!push_uniq(s.enclosed, redef)) break;
|
||||
if (s === redef.scope) break;
|
||||
}
|
||||
} else if (node instanceof AST_SymbolConst) {
|
||||
@@ -480,7 +480,7 @@ AST_Lambda.DEFMETHOD("init_vars", function(parent_scope) {
|
||||
AST_Symbol.DEFMETHOD("mark_enclosed", function(options) {
|
||||
var def = this.definition();
|
||||
for (var s = this.scope; s; s = s.parent_scope) {
|
||||
push_uniq(s.enclosed, def);
|
||||
if (!push_uniq(s.enclosed, def)) break;
|
||||
if (!options) {
|
||||
s._var_names = undefined;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user