E4204

E4204#

Compiler diagnostic name: loop_nobreak_not_supported.

The loop expression does not support a nobreak block. nobreak is for loop forms where normal completion is possible, while loop is an explicit functional loop that continues or breaks from its body.

Erroneous example#

///|
fn count_down(n : Int) -> Int {
  loop n {
    0 => break 0
    i => continue i - 1
  } nobreak {
    -1
  }
}

///|
test {
  ignore(count_down)
}

Suggestion#

Rewrite the code as a for loop when you need loop state and an explicit result.

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

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