std/core/void
std/core/src/void.trb
Void, the result of a function that says nothing, Never, the type of an expression that never produces a
value, and panic, which is how a bug ends a program instead of returning one.
type Void
native type Void with Equals, Hash, Show
The type with exactly one value, and that value is the keyword literal void - as true and false are the values
of Bool. Void is the result type of a function that declares none:
fn start(): Result<Void, AppError> {
setUp()?
Ok(void)
}
A block that ends in a statement has the value void, too. It carries nothing, so it is no way from a type to a
value: there is nothing to look at.
type Never
native type Never
The type of an expression that does not return: panic, return, break, continue. It has no value at all,
which is why it converts to every type - const port = config.port ?? panic "no port" type checks as an Int.
fn panic
native fn panic(message: String): Never
For bugs. Not catchable: it writes panic: <message> and then at src/file.trb:12:5 to standard error - in the
debug profile the frames of the task as well - and ends the program with exit code 101. Nothing else runs on the way
out: no Close, no using cleanup. Running more code in a broken program is how bugs get worse.
The one place a panic is recoverable is inside a sandboxed script, where the VM stops it and Script.apply returns
a SandboxError.
It lives next to Never, its result type, and in std/core rather than in std/console, because Result.expect
and every out-of-bounds index need it: the package everything depends on cannot depend on the printing one.