bynk.parse.let_pattern_without_else
Error A let binds a pattern but has no else saying what the block produces when the value does not match; only a record pattern that cannot fail may omit it.
A let that takes a value apart with a pattern must say what the block produces when the value does not match, so it needs an else. Only a record pattern that cannot fail (every field a bare name, f: name or f: _) may leave it out. Add else { … } after the value, or write a match. The note names the first field that can fail to match.
Example
fn head(xs: List[Int]) -> Int { let [x, ..] = xs // ✗ an empty list does not match x}
fn head(xs: List[Int]) -> Int { let [x, ..] = xs else { 0 } // ✓ says what an empty list gives x}In the Book
See also
- The grammar rule it governs:
let_else_stmt. - Every code in its category, Parser, on the diagnostic index.
bynk explain bynk.parse.let_pattern_without_elseshows the same from the installed toolchain, without a network.