Crash
crash says that carrying on makes no sense.
The crash Statement
The operand of crash must be an error value, expressing a terminal state with information attached:
error ConfigMissing(what: string);
func main() -> int
{
print("before");
crash new ConfigMissing("port");
print("after");
}before
mush: MS6000: Runtime error: runtime crash: crash.crash does not travel the fail channel, offers no recovery, and terminates the process outright (exit code 1). Statements after a crash get an unreachable warning at compile time; unlike fail, defers do not run on a crash path.
Hard Errors Are Crashes Too
Runtime hard errors such as out-of-range indexes and missing keys surface as crash terminal states and produce no catchable value:
mush: MS6000: Runtime error: List index out of range (index=9, count=3).- recover cannot intercept a crash. recover consumes fail error values only; it has no interception point for bugs like an out-of-range index.
- crash skips defers. Defers run only as failures propagate; a crash is terminal and runs no cleanup.
- Messages carry
@siteand the key values.index=9, count=3and the missing key’s value are all written into the crash message, making the problem easy to locate.
Notes
- Choosing between crash and fail: bugs may crash, domain failures fail, and “maybe absent” uses nullable types;
- Hard-error crash messages carry location information themselves; no manual wrapping in code is needed.
Last updated on October 11, 2026
