kw match
Reserved keyword
The list of words: §1.4
Syntax
Match = "match" Expr "{" { Pattern [ "if" Expr ] "=>" Expr ( "," | NL ) } "}" ;Grammar: App. A
Defined in
- 5.5 Pattern matching — A match MUST be exhaustive.
- 3.5 Unions and optionals — A | B — an anonymous union.
- 4.4 enum — A variant: without fields, with positional or with named fields.
- 5.1 General rules — Almost everything is an expression
- 5.4 Conditions — There is no ternary operator.
- 6.5 Errors — There are no exceptions.
- 1.4 Keywords — Reserved (cannot be used as names)
Examples
match result {
Receipt r if r.amount > LIMIT => review(r)
Receipt r => ok(r)
Declined(reason) => warn(reason)
Timeout | Unavailable => retryLater()
_ => fail Unknown
}Related diagnostics
non-exhaustive, pattern-bindings, unreachable-arm, type-mismatch, not-assignable, fail-type, question-context, unhandled-error