Vanta
Vanta is a statically typed language and tree-walk interpreter written in C11. Preconditions and postconditions are built into the language, with old(expr) preserving a value from when a function is entered.
- During lowering, old(expr) nodes are moved ahead of the function body so their values are captured on entry, letting postconditions compare the final state against the initial state.
- Contracts marked with @debug are omitted during lowering in release builds, avoiding runtime flag checks on each call.
- Preconditions and postconditions pass through the same symbol table and type checker as function bodies, rejecting type mismatches and state mutations before execution.
@debug @requires(s.size < s.capacity)
@debug @ensures(s.size == old(s.size) + 1)
fn push(s: *Stack, v: int) {
s.data[s.size] = v;
s.size += 1;
}