Skip to main content

loop_needs_break_label

Function loop_needs_break_label 

Source
pub fn loop_needs_break_label(body: &AIRNode) -> bool
Expand description

Decide whether a loop must be given a target label so that a break/ continue inside a statement-arm match reaches the loop rather than the switch the match lowers to.

In Go and JS/TS, break inside a switch exits the switch. When a statement-arm match (lowered to a switch) contains a break (or, in Go-style lowering, a continue) intended for an enclosing loop, the loop needs a label and the jump must be labelled. This returns true when the loop body contains — without crossing into a nested loop or function — a match with a statement arm that performs a break/continue.