kw fail
Reserved keyword
The list of words: §1.4
Syntax
Primary = Literal | Path | "it" | "self" | "(" Expr { "," Expr } ")" | ListLit | MapLit
| StructLit | Lambda | Block | If | Match | For | While | Loop | Scope | Select | Query
| "spawn" ( Postfix | Block ) | "await" Unary | "atomic" [ "(" Args ")" ] Block
| "return" [ Expr ] | "fail" Expr | "yield" Expr | "respond" Expr | "break" [ Label ] [ Expr ]
| "continue" [ Label ] | "emit" Path "(" Expr ")" | "unsafe" Block | "blocking" Block
| "comptime" Block | "." Ident [ "(" [ Args ] ")" ] ;Grammar: App. A
Defined in
- 5.8 Other expressions — defer e — executes e on leaving the block (including on fail, return, cancellation), in the reverse order of declaration.
- 6.5 Errors — There are no exceptions.
- 3.1 Primitives — Integer arithmetic.
- 8.4 Chains — A chain links asynchronous steps so that either the whole chain is executed or the first unhandled error is returned.
- 10.3 Streams — The type is stream<T, E = never>.
- 18.4 Simulation — In sim the scheduler, network, clocks, randomness and disk failures are deterministic; the result depends only on the seed.
- 1.4 Keywords — Reserved (cannot be used as names)
- 4.3 Construction and constructors — Literal. T{ f1: e1, f2, ..base }
Examples
@error data NotFound { what: str }
@error enum PayError { Declined(reason: str), Fraud }
fn charge(card: Card, sum: Money) -> Receipt | PayError | NetError net {
let token = Vault.tokenize(card)? // ? propagates the errors of the call
if sum <= Money.zero() { fail PayError.Declined("zero sum") }
Bank.pay(token, sum)
}Related diagnostics
fail-type, question-context, unhandled-error, it-outside-chain, yield-outside-stream, bad-init, missing-field, must-close, positional-literal, sealed-literal