E3007

E3007#

Wrong location of .. in a record pattern. Put .. after the last field in the pattern.

Erroneous example#

pub(all) struct S {
  a : Int
  b : Int
  c : Int
}

fn sum_selected(s : S) -> Int {
  let { a, .., c } = s
  a + c
}

test {
  inspect(sum_selected({ a: 1, b: 2, c: 3 }), content="4")
}

Suggestion#

Move .. to the end of the record pattern, after all fields that you want to bind:

///|
pub(all) struct S {
  a : Int
  b : Int
  c : Int
}

///|
fn sum_selected(s : S) -> Int {
  let { a, c, .. } = s
  a + c
}

///|
test {
  inspect(sum_selected({ a: 1, b: 2, c: 3 }), content="4")
}