E4107#
Name is declared multiple times in this for-loop.
This error occurs when the same variable name is declared multiple times in the initialization block of a for-loop. In a for-loop’s initialization, each variable must have a unique name to avoid ambiguity about which value should be used.
错误示例#
pub fn f(x: Int) -> Unit {
for i = 0, i = 1; i < x; i = i + 1 {
// ^ --- Error: i is declared multiple times in this for-loop
println(i)
}
}
建议#
To fix this error, you can change the variable name in the initialization block:
pub fn f(x: Int) -> Unit {
for i = 0, j = 1; i < x; i = i + 1 {
println(i)
}
}