void and never, which both describe the absence of a value, but with different semantics.
void
A function that returns nothing is void. Both functions below return void:
return without a value indicates a void return type.
Explicitly specifying fun(...): void behaves identically:
void-typed fields
A structure field with type void is treated as non-existent. This pattern is used with generics such as <T = void> to model optional fields in structure types.
never
A function that never returns is never. A function whose execution always terminates by throwing an error has return type never:
match expression, branches that do not return are inferred as never:
Implicit never in unreachable branches
The type never represents values that cannot exist. It occurs implicitly in branches that the type system can prove to be unreachable.
Here, the condition cannot be satisfied:
null:
never in a compilation error typically indicates an issue in the preceding code.
Stack layout and serialization
Bothvoid and never represent the absence of a value. At the TVM level, neither type produces a value on the stack and occupies zero stack slots and zero bits. For example, a function with return type void does not place any value onto the stack.