A plain let, a for loop and function parameters bind with patterns that must match every
value. This one might not; the message shows a value it misses. Auk never fails a binding
silently at run time.
Wrong#
fn head(xs: [int]): int {
let [h, ..t] = xs
h
}Fixed#
fn head(xs: [int]): int {
let [h, ..t] = xs else { return 0 }
h
}Common causes#
- Destructuring a list, enum or literal with a plain
let: addelse { ... }, or usematch. for Circle(r) in shapes: filter first, ormatchinside the loop.