fix corner case in merge_vars (#5437)

fixes #5436
This commit is contained in:
Alex Lam S.L
2022-05-07 21:16:28 +01:00
committed by GitHub
parent 89a35f9fcd
commit 35c2149dbd
2 changed files with 33 additions and 2 deletions

View File

@@ -6102,9 +6102,10 @@ Compressor.prototype.compress = function(node) {
if (prop.static) { if (prop.static) {
prop.value.walk(tw); prop.value.walk(tw);
} else { } else {
push(tw); push();
segment.block = node;
prop.value.walk(tw); prop.value.walk(tw);
pop(tw); pop();
} }
}); });
return true; return true;

View File

@@ -2571,3 +2571,33 @@ issue_5389: {
expect_stdout: "PASS PASS" expect_stdout: "PASS PASS"
node_version: ">=12" node_version: ">=12"
} }
issue_5436: {
options = {
merge_vars: true,
}
input: {
function f(a) {
class A {
p = a;
}
var b = "FAIL";
A == b && b();
return new A();
}
console.log(f("PASS").p);
}
expect: {
function f(a) {
class A {
p = a;
}
var b = "FAIL";
A == b && b();
return new A();
}
console.log(f("PASS").p);
}
expect_stdout: "PASS"
node_version: ">=12"
}