Skip to content

Commit

Permalink
fix(linter): edge case with infinite loops. (#3672)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
rzvxa committed Jun 14, 2024
1 parent abd6ac8 commit cf71c23
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_unreachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -256,6 +258,15 @@ fn test() {
}
c();
",
"
try {
while (true) {
a();
}
} catch {
b();
}
",
];

let fail = vec![
Expand Down

0 comments on commit cf71c23

Please sign in to comment.