@@ -851,6 +851,9 @@ var AST_DefClass = DEFNODE("DefClass", null, {
|
|||||||
$propdoc: {
|
$propdoc: {
|
||||||
name: "[AST_SymbolDefClass] the name of this class",
|
name: "[AST_SymbolDefClass] the name of this class",
|
||||||
},
|
},
|
||||||
|
resolve: function(def_class) {
|
||||||
|
return def_class ? this : this.parent_scope.resolve();
|
||||||
|
},
|
||||||
_validate: function() {
|
_validate: function() {
|
||||||
if (!(this.name instanceof AST_SymbolDefClass)) throw new Error("name must be AST_SymbolDefClass");
|
if (!(this.name instanceof AST_SymbolDefClass)) throw new Error("name must be AST_SymbolDefClass");
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3269,7 +3269,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
if (def.scope.resolve() !== scope) return true;
|
if (def.scope.resolve() !== scope) return true;
|
||||||
if (modify_toplevel && compressor.exposed(def)) return true;
|
if (modify_toplevel && compressor.exposed(def)) return true;
|
||||||
return !all(def.references, function(ref) {
|
return !all(def.references, function(ref) {
|
||||||
return ref.scope.resolve() === scope;
|
return ref.scope.resolve(true) === scope;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2538,3 +2538,34 @@ issue_5387: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5389: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function log(m, n) {
|
||||||
|
console.log(m, n);
|
||||||
|
}
|
||||||
|
var a = log;
|
||||||
|
class A {
|
||||||
|
[a = "FAIL"] = a = "PASS";
|
||||||
|
}
|
||||||
|
var b = new A();
|
||||||
|
log(a, b.FAIL);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function log(m, n) {
|
||||||
|
console.log(m, n);
|
||||||
|
}
|
||||||
|
var a = log;
|
||||||
|
class A {
|
||||||
|
[a = "FAIL"] = a = "PASS";
|
||||||
|
}
|
||||||
|
var b = new A();
|
||||||
|
log(a, b.FAIL);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS PASS"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user