Error codes

E0245: bad break value

In a terminal: auk explain E0245 prints this page.

On this page

Only loop is an expression that can produce a value with break v; for and while may stop before running at all, so they have no value to break with.

Wrong#

auk
fn main() {
  while true { break 1 }
}

Fixed#

auk
fn main() {
  let v = loop { break 1 }
  print(v)
}

Common causes#

  • break value in a for or while: use loop, or find/find_index to search.
  • A break value whose type doesn't match the other breaks of the same loop.

Stuck on a word? Try the glossary. Got a compiler error? Look up its code. Improve this page