E4204

Contents

E4204#

Compiler diagnostic name: loop_nobreak_not_supported.

This diagnostic applies to a nobreak clause on the deprecated functional-loop syntax. Use a for loop with explicit state bindings instead.

Suggestion#

Use break with a value to return the result. A for loop without a condition continues until an explicit exit, so no nobreak clause is needed:

///|
fn count_down(n : Int32) -> Int32 {
  for i = n {
    if i == 0 {
      break 0
    }
    continue i - 1
  }
}

///|
test {
  inspect(count_down(3), content="0")
}