E0052

E0052#

A loop variable is not updated in loop.

When a loop variable is not updated, this could be a potential bug that you have forgotten to update it, leading to an infinite loop.

错误示例#

///|
pub fn f() -> Unit {
  for i = 0, radix = 10; i < 10; {
    println(i.to_string(radix~))
  }
}

建议#

有几种方式可以修复这个警告:

  • If this variable is indeed constant during the loop, you can remove it from the initialization and make it constant

  • If your code depends on change of the variable, you should update it somewhere in the loop.

///|
pub fn f() -> Unit {
  let radix = 10
  for i = 0; i < 10; i = i + 1 {
    println(i.to_string(radix~))
  }
}