LYR-PAR0033
a malformed pattern
Where a pattern stands, the token begins none; a - in a pattern is not followed by a number; a range pattern's bound is no literal; or an array pattern holds two rests ...
Explanation
A pattern is a literal or a range of literals, a name that binds, _, a variant, a tuple, an array, or a type test. Only a number is negated in a pattern, and the bounds of a range are literals, so no pattern runs code. An array pattern takes at most one ..: with two, the positions between them could not be placed.
Write a pattern of one of these forms.
Wrong
fn main(): void {
let xs = [1, 2, 3];
let n = match (xs) {
[a, .., ..] => a,
_ => 0,
};
}
Right
fn main(): void {
let xs = [1, 2, 3];
let n = match (xs) {
[a, ..] => a,
_ => 0,
};
let _ = n;
}