A list pattern can have at most one .. (the rest of the list). With two, it is unclear how
many items each one takes.
Wrong#
fn ends(xs: [int]): int = match xs {
[a, .., b, ..] => a + b
_ => 0
}Fixed#
fn ends(xs: [int]): int = match xs {
[a, .., b] => a + b
_ => 0
}Common causes#
- Trying to match an element in the middle of a list: use
findor a loop. - A leftover
..after an edit.