E4112#
The usage of a 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)
}
}
}
A continue also cannot target a labelled block. Use break to exit a
labelled block, or target an enclosing labelled loop with continue.
///|
pub fn skip_block() -> Unit {
block~: {
continue block~
}
}
///|
pub fn skip_block() -> Unit {
block~: {
break block~
}
}