Skip to main content

body_breaks_outward

Function body_breaks_outward 

Source
pub fn body_breaks_outward(body: &[Statement]) -> bool
Expand description

Whether a statement list contains a function-level return anywhere — looking through control flow (including nested trys and their handlers) but not into nested function or class definitions. The try lowering uses this to pick its closure’s carrier type: bodies with returns thread the returned value out through PyFlow. Does this statement list contain a break/continue that targets a loop OUTSIDE the list? A loop nested within the list owns its own breaks, so its body is not searched — but its else clause is, since a break there targets the enclosing loop, as in Python. Nested function and class bodies are separate scopes and never searched.