E4111#
The usage of break statement is invalid.
This error happens when you use a break 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 = ({
break
})
j < y
j = j + 1 {
// ^^^^^ Error: The usage of break statement is invalid.
println(i + j)
}
}
}
Suggestion#
Do not write a break 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 i + j > 10 {
break
}
println(i + j)
}
}
}