Reference documentation, not a pitch
WAST
A typed source language that stays close to the WebAssembly instruction set. It exists to make writing WebAssembly by hand less tedious, not to be a general-purpose language. It is basic, low-level, and small on purpose — this is what it is, not what it's becoming.
global Counter: mut i32 = 0;func increment() -> i32 {Counter = Counter + 1;return Counter;}Read this before you write anything real: this is a from-scratch, single-maintainer compiler with no unit tests, no release process, and documented cases of control-flow bugs that produced valid-but-wrong WebAssembly. See limitations and rough edges.
In the language
- Typed source close to Wasm: i32/i64/f32/f64, no implicit conversion
- GC structs (nominal, inheriting), arrays, i31, casts, flow-sensitive narrowing
- Structured control flow: labeled block/loop, for, is-tests
- Packed i8/i16 fields, data segments, typed function references
- A wasm.<opcode> escape hatch for the instruction catalog
- Readable, comment-annotated WAT output
- An LSP: hover, completion, rename, references, go-to-def, semantic tokens
Not in the language
- Exception handling, SIMD, threads, memory64, stringref
- Source-level tail calls (only a --tail-calls output flag on your own return)
- A raw call_ref, or any branch instruction in the wasm.* escape hatch
- Module linking — one file compiles to exactly one module
- Unicode identifiers, block comments
- Any stability guarantee whatsoever
GC types
References carry nullability in the spelling.
&Type is non-null, ?Type is nullable. Structs inherit nominally; arrays are one element type, explicitly allocated.
struct Shape {area: f64,}struct Circle : Shape {radius: f64,}let circle: &Circle =new Circle { area: 3.14, radius: 1.0 };Look it up
Reference, not a tutorial.
- Syntax cheat sheetEvery construct, operator precedence, arity rules, naming conventions
- Opcode catalogAll 199 wasm.* operations, immediate forms, and what's deliberately absent
- DiagnosticsEvery error message, its cause, and the three things that fail silently
- ToolingCLI flags, exit codes, the LSP, the test harness, tree-sitter
Output, not a black box
Every instruction traces back to a source line.
Output is WAT text with a comment above each generated instruction sequence naming the declaration or statement that produced it. Binary output and any optimization are separate, explicit, opt-in steps — never on by default.
Tooling and CLI