@@ -606,7 +606,11 @@ merge(Compressor.prototype, {
|
||||
var safe = tw.safe_ids[def.id];
|
||||
if (!HOP(tw.safe_ids, def.id)) {
|
||||
if (!safe) return false;
|
||||
if (safe.read && def.scope.resolve() !== tw.find_parent(AST_Scope)) return false;
|
||||
if (safe.read) {
|
||||
var scope = tw.find_parent(AST_BlockScope);
|
||||
if (scope instanceof AST_Class) return false;
|
||||
if (def.scope.resolve() !== scope.resolve()) return false;
|
||||
}
|
||||
safe.assign = safe.assign && safe.assign !== tw.safe_ids ? true : tw.safe_ids;
|
||||
}
|
||||
if (def.fixed != null && safe.read) {
|
||||
|
||||
@@ -1748,3 +1748,47 @@ issue_4992: {
|
||||
expect_stdout: "function"
|
||||
node_version: ">=12"
|
||||
}
|
||||
|
||||
issue_4996_1: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
var a = 1;
|
||||
console.log(new class A {
|
||||
p = a-- && new A();
|
||||
}().p.p);
|
||||
}
|
||||
expect: {
|
||||
var a = 1;
|
||||
console.log(new class A {
|
||||
p = a-- && new A();
|
||||
}().p.p);
|
||||
}
|
||||
expect_stdout: "0"
|
||||
node_version: ">=12"
|
||||
}
|
||||
|
||||
issue_4996_2: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a = 1;
|
||||
console.log(new class A {
|
||||
p = a-- && new A();
|
||||
}().p.p);
|
||||
}
|
||||
expect: {
|
||||
var a = 1;
|
||||
console.log(new class A {
|
||||
p = a-- && new A();
|
||||
}().p.p);
|
||||
}
|
||||
expect_stdout: "0"
|
||||
node_version: ">=12"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user