Skip to content
ZOLO / TE229 Type · error

loop break value type mismatch

Compiler diagnostic TE229: loop break value type mismatch.

Why this fires

The values carried by reachable exits do not agree with the result type of a loop expression. A bare break contributes void, so it cannot exit a loop that is expected to produce a non-void value.

fn answer() -> int {
    loop {
        if ready() { break 42 }
        break // error[TE229]: expected int, found void
    }
}

Fix it

Give every reachable break targeting that loop a compatible value, or use the loop only for control flow when it should not produce a result.

See also

  • TE228 — a break value targets while or for.

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

en