E3008

E3008#

数组模式中有多个 .. 模式。每个数组模式中最多只能使用一个 ..

错误示例#

fn outer_sum(array : Array[Int]) -> Int {
  let [fst, .., .., snd] = array
  fst + snd
}

test {
  inspect(outer_sum([1, 2, 3, 4, 5]), content="6")
}

建议#

移除多余的 .. 模式。

///|
fn outer_sum(array : Array[Int]) -> Int {
  match array {
    [fst, .., snd] => fst + snd
    _ => 0
  }
}

///|
test {
  inspect(outer_sum([1, 2, 3, 4, 5]), content="6")
}