E4112

E4112#

The usage of continue statement is invalid.

This error happens when you use a continue statement in the initialization, condition, or update statement of a loop.

Erroneous example#

///|
pub fn f(x : Int, y : Int) -> Unit {
  for i = 0; i < x; i = i + 1 {
    for j = ({
            continue
          })
        j < y
        j = j + 1 {
      //            ^^^^^^^^ Error: The usage of continue statement is invalid.
      println(i + j)
    }
  }
}

Suggestion#

Do not write a continue statement in the initialization, condition, or update statement of a loop. Put it in the loop body instead.

///|
pub fn f(x : Int, y : Int) -> Unit {
  for i = 0; i < x; i = i + 1 {
    for j = 0; j < y; j = j + 1 {
      if j == 0 {
        continue
      }
      println(i + j)
    }
  }
}