Apart from being a value of the type logic
, false
is also a type that has no possible values. As a return type, it indicates that the function doesn’t return a value. The only way to do this right now is using the Err
function, which is defined as:
# Halts the Verse runtime with error `Message`.
Err(Message:string)<computes>:false
The reason why it’s valuable to have such a type with no possible values is that it’s a subtype of all other types, also known as the bottom type. You can use a value from :false
without regard for what value is expected, and an expression like or
or if
that joins possible results from different branches into a single type can ignore unreachable branches. For example:
MaybeInt:?int=...
MyInt:int = MaybeInt? or Err("expected MaybeInt to be set")
The left-hand-side of the or
yields a value from :int
, and the right-hand-side of the or
yields a value from :false
. This means the combined expression will yield a value from the join :int | :false
, but because :false
has no possible values this simplifies to :int
, and the compiler accepts binding the result to MyInt:int
.