From 7a58fec6b535a22f178515372ff905f2a59751bc Mon Sep 17 00:00:00 2001 From: rzvxa <3788964+rzvxa@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:38:49 +0000 Subject: [PATCH] fix(semantic/cfg): issue in unlabeled `Ctx`s. (#3678) [oxlint-ecosystem-ci](https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9519079285) --- crates/oxc_semantic/src/control_flow/builder/context.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/oxc_semantic/src/control_flow/builder/context.rs b/crates/oxc_semantic/src/control_flow/builder/context.rs index ff54a935b60e6..19b73ea2d5195 100644 --- a/crates/oxc_semantic/src/control_flow/builder/context.rs +++ b/crates/oxc_semantic/src/control_flow/builder/context.rs @@ -240,7 +240,12 @@ impl<'a> ControlFlowGraphBuilder<'a> { .filter(|it| it.flags.contains(flag)) .find(|it| it.is(label)) } else { - self.ctx_stack.iter_mut().rev().find(|it| it.flags.contains(flag)) + self.ctx_stack + .iter_mut() + .rev() + // anything up the function is unreachable + .take_while(|it| !it.flags.intersects(CtxFlags::FUNCTION)) + .find(|it| it.flags.contains(flag)) }; if let Some(ctx) = ctx {