E3008

E3008#

There are multiple .. patterns in an array pattern. Use at most one .. in each array pattern.

Erroneous example#

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

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

Suggestion#

Remove the extra .. pattern.

///|
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")
}