mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(linter): edge case with infinite loops. (#3672)
closes #3663 this time for real😅 browser search doesn't work in the GitHub actions (because of the partial rendering I guess) I had to use GitHub's own log search to see all instances related to this rule. [oxlint-ecosystem-ci](https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9512820948)
This commit is contained in:
parent
abd6ac8811
commit
cf71c23d93
1 changed files with 13 additions and 2 deletions
|
|
@ -6,7 +6,7 @@ use oxc_semantic::{
|
|||
visit::{depth_first_search, Control, DfsEvent, EdgeRef},
|
||||
Direction,
|
||||
},
|
||||
EdgeType, InstructionKind,
|
||||
EdgeType, ErrorEdgeKind, InstructionKind,
|
||||
};
|
||||
use oxc_span::{GetSpan, Span};
|
||||
|
||||
|
|
@ -84,7 +84,9 @@ impl Rule for NoUnreachable {
|
|||
// `NewFunction` is always reachable
|
||||
| EdgeType::NewFunction
|
||||
// `Finalize` can be reachable if we encounter an error in the loop.
|
||||
| EdgeType::Finalize => true,
|
||||
| EdgeType::Finalize
|
||||
// Explicit `Error` can also be reachable if we encounter an error in the loop.
|
||||
| EdgeType::Error(ErrorEdgeKind::Explicit) => true,
|
||||
|
||||
// If we have an incoming `Jump` and it is from a `Break` instruction,
|
||||
// We know with high confidence that we are visiting a reachable block.
|
||||
|
|
@ -256,6 +258,15 @@ fn test() {
|
|||
}
|
||||
c();
|
||||
",
|
||||
"
|
||||
try {
|
||||
while (true) {
|
||||
a();
|
||||
}
|
||||
} catch {
|
||||
b();
|
||||
}
|
||||
",
|
||||
];
|
||||
|
||||
let fail = vec![
|
||||
|
|
|
|||
Loading…
Reference in a new issue