fix corner case in conditionals (#5547)

fixes #5546
This commit is contained in:
Alex Lam S.L
2022-07-07 08:49:33 +01:00
committed by GitHub
parent 3dcf098468
commit 902292f776
2 changed files with 112 additions and 0 deletions

View File

@@ -1185,6 +1185,11 @@ var AST_Try = DEFNODE("Try", "bcatch bfinally", {
bcatch: "[AST_Catch?] the catch block, or null if not present", bcatch: "[AST_Catch?] the catch block, or null if not present",
bfinally: "[AST_Finally?] the finally block, or null if not present" bfinally: "[AST_Finally?] the finally block, or null if not present"
}, },
_equals: function(node) {
return all_equals(this.body, node.body)
&& prop_equals(this.bcatch, node.bcatch)
&& prop_equals(this.bfinally, node.bfinally);
},
walk: function(visitor) { walk: function(visitor) {
var node = this; var node = this;
visitor.visit(node, function() { visitor.visit(node, function() {

View File

@@ -2243,3 +2243,110 @@ issue_5544_2: {
} }
expect_stdout: "PASS" expect_stdout: "PASS"
} }
issue_5546_1: {
options = {
conditionals: true,
}
input: {
var a;
if (a)
try {
console;
} finally {
console.log("FAIL");
}
else
try {
console;
} finally {
console.log("PASS");
}
}
expect: {
var a;
if (a)
try {
console;
} finally {
console.log("FAIL");
}
else
try {
console;
} finally {
console.log("PASS");
}
}
expect_stdout: "PASS"
}
issue_5546_2: {
options = {
conditionals: true,
}
input: {
var a;
if (a)
try {
console;
} catch (e) {}
else
try {
console;
} finally {
console.log("PASS");
}
}
expect: {
var a;
if (a)
try {
console;
} catch (e) {}
else
try {
console;
} finally {
console.log("PASS");
}
}
expect_stdout: "PASS"
}
issue_5546_3: {
options = {
conditionals: true,
}
input: {
var a;
if (a)
try {
FAIL;
} catch (e) {
console.log("FAIL");
}
else
try {
FAIL;
} catch (e) {
console.log("PASS");
}
}
expect: {
var a;
if (a)
try {
FAIL;
} catch (e) {
console.log("FAIL");
}
else
try {
FAIL;
} catch (e) {
console.log("PASS");
}
}
expect_stdout: "PASS"
}