E4103

E4103#

This loop has incorrect number of patterns supplied.

This error occurs when the number of patterns in a loop arm does not match the number of loop arguments. In a loop construct, each arm must have the same number of patterns as there are loop arguments.

For example, if a loop takes 2 arguments, each arm must have exactly 2 patterns to match against those arguments. Having too few or too many patterns will trigger this error.

错误示例#

pub fn f(x: Int, y: Int) -> Int {
  loop x, y {
    0, 0 => 0
    a => continue a - 1, 0
//  ^ Error: This loop has 2 arguments, but 1 patterns are supplied
  }
}

建议#

To fix this error, ensure that each arm in the loop has the correct number of patterns to match the loop arguments. For example,

pub fn f(x: Int, y: Int) -> Int {
  loop x, y {
    0, 0 => 0
    a, b => continue a - 1, b - 1
  }
}