fix corner cases in dead_code & if_return (#5525)

fixes #5521
fixes #5522
fixes #5523
fixes #5524
This commit is contained in:
Alex Lam S.L
2022-06-26 11:40:56 +01:00
committed by GitHub
parent 8b464331ba
commit fcc87edb71
3 changed files with 109 additions and 6 deletions

View File

@@ -230,7 +230,6 @@ labels_12: {
conditionals: true,
dead_code: true,
if_return: true,
unused: true,
}
input: {
L: try {
@@ -246,13 +245,14 @@ labels_12: {
}
}
expect: {
try {
L: try {
if (!console.log("foo"))
throw "bar";
} catch (e) {
console.log(e);
} finally {
console.log("baz")
if (console.log("baz"))
break L;
}
}
expect_stdout: [
@@ -381,3 +381,53 @@ issue_4466_2_toplevel_v8: {
}
expect_stdout: "PASS"
}
issue_5522: {
options = {
dead_code: true,
}
input: {
console.log(function() {
L: try {
return "FAIL";
} finally {
break L;
}
return "PASS";
}());
}
expect: {
console.log(function() {
L: try {
return "FAIL";
} finally {
break L;
}
return "PASS";
}());
}
expect_stdout: "PASS"
}
issue_5524: {
options = {
dead_code: true,
}
input: {
L: try {
FAIL;
} finally {
break L;
}
console.log("PASS");
}
expect: {
L: try {
FAIL;
} finally {
break L;
}
console.log("PASS");
}
expect_stdout: "PASS"
}