# Lane: the whole language reference > Lane is a data-oriented systems language: explicit SoA/AoS layout, explicit SIMD, multithreading as keywords, and tests, benchmarks and coverage built into the compiler. One source for every ISA. ## What is Lane Lane is a compiled systems programming language for software where data layout and speed decide the result, such as game engines, game servers and databases. Data layout is part of the type, SIMD is explicit and written once for every instruction set, threads are in the language, and tests live in the declaration of the function they check. - Lane builds a million lines into a running executable in 225 ms on 16 threads (prototype, 2026-10-14); on one thread the in-memory build phases take 1,105 ms (2026-10-18), and the goal is under one second. - Lane is a data-oriented programming language: SoA and AoS are keywords on array types, so the layout is part of the type, and lean packed types keep data compact. - Lane is a SIMD programming language with one source for every ISA: vec loops must vectorize at the target's native width or the build fails, per-ISA code is chosen with when, and the targets include x86-64, AArch64, WebAssembly, RISC-V and SPIR-V. - Lane is a programming language with built-in tests and contracts: a test is one line in the function's declaration, about 8 tokens, and the compiler runs it during the build; an estimate puts the saving at about 25% fewer tokens for well-tested code (2026-10-14). - Lane is a systems programming language for game engines: data layout is part of the type, threads are in the language with access modes that make conflicts checkable, and struct-of-arrays data fits the entity-component pattern. This file is generated from the pages of the site. It holds the language documentation, the one-page cheat sheet, the error reference, the targets, the roadmap, the measurements and the use cases. Docs updated 2026-10-15. The verified-examples index is left out for length: it is at https://lane.trisgram.com/docs/agents/examples.md. --- # Lane in one page > Every construct with one minimal example, and the exact rules an agent gets wrong without them. Lane is statically typed, compiled ahead of time, with plain data and no hidden work: nothing allocates, bounds-checks or converts behind your back. Source files are ASCII, one file is one module, extension `.ln`. The Status section of the [agent docs](https://lane.trisgram.com/docs/agents.md) says which constructs the current compiler accepts. ## The rules agents get wrong 1. **Every simple statement ends with `;`**, including the last one in a block. A construct that ends with a `}` block takes none: a function, `rec`, `enum`, `union`, `if`, `for`, `vec`, `par`, `match`, `when`, `asm`, `test`, `bench`. Declarations without a body end with `;`: `use`, constants (`N :: 1;`) and `ext` imports. Record and union fields end with `;` too. Newlines mean nothing. 2. **Declarations are type first**: `u32 n = 0;`, `f32 dt` (parameter), `u64 gcd(u64 a, u64 b) {`. There is no `fn`, `let`, `var` or `:` before the type. The `fn` keyword appears only inside a function type: `f32 fn(f32, f32)`. 3. **The keywords are `ret`, `brk`, `nxt`** (not `return`, `break`, `continue`). There is no `while`; write `for cond { }`. There is no `null`; the null pointer is `nil`, and `nul` is the empty type (a function that returns nothing returns `nul`). 4. **There are no implicit conversions.** `u32 + u64` is an error; write `u64(a) + b`. An integer converts to another type only with `T(x)`. The one exception is an array becoming a slice of its elements. A `bool` does convert to any integer type, as the 0 or 1 it is (`u32(a < b)`); there is no conversion from an integer to `bool`, so write `x != 0`. 5. **A bare literal has no type of its own.** It takes its type from where it is used and must fit. `a := 1;` is an error, so is `for i in 0..10`. Write `u32 a = 1;`, `a := u32(1);`, `for i in u32(0)..10`. A literal next to a typed operand takes that operand's type (`x + 1`), and `for i in 0..s.len` is fine because `s.len` is a `usz`. 6. **Access modes are repeated at the call.** A parameter is read-only unless declared `wr` (read and write) or `out` (write, must be assigned on every path). The caller writes the same word in front of the argument: `run(code, wr vm)`. A missing or different mode is an error. 7. **Conditions must be `bool`.** `if n { }` is an error; write `if n != 0 { }`. No parentheses are needed: `if a < b { }`. 8. **Arithmetic wraps** (two's complement, never undefined). Division by zero is not checked; the processor faults. Shifts take the count modulo the width. There are **no bounds checks** on arrays and slices. 9. **No shadowing**: a name that is visible cannot be declared again, parameters and loop variables included. After its block ends the name is free. 10. **A function that returns a value must end every path with `ret`.** The check looks at the shape of the code, not at values: `for true { }` can be left, `for { }` cannot. 11. **Arrays are memory, never copied.** You cannot assign, compare or return a whole array; a record can be assigned (`a = b;` copies it) but cannot be returned yet or passed through the C ABI (use an `out` or pointer parameter). There are no record or array literals yet; they are an open question in the specification. 12. **Source is ASCII only**: tab, line feed, carriage return and bytes 0x20 to 0x7e. Any other byte is a lexical error, even inside a string or comment. Write other bytes as `\xNN` in a string or character literal. 13. **Reserved names, exactly.** (a) The keywords in the table below, and `ct` and `try`, are never identifiers. (b) The names `size_of`, `align_of`, `cast`, `slice`, `nul` and the scalar type names (`i8` ... `usz`, `bool`, `f16`, `f32`, `f64`) cannot be declared as a function, constant, record, enum, parameter, variable or loop variable, because they would be in scope by their own name. (c) A field or an enum variant may have any of those names, since it is only reached through its record or enum. (d) Other predeclared names, such as the hints `likely` and `assume`, are ordinary identifiers. 14. **A top-level declaration may come in any order** and there are no headers or forward declarations. `main` is `nul main()` or `i32 main()`; the `i32` result is the exit code. 15. **An expression statement must be a call.** `a + 1;` is an error. ## Reserved names: what is refused and what is allowed Refused (rule 13b): declaring one of the reserved predeclared names as something in scope. ```lane i8 :: 1; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: `i8` is a predeclared type and cannot be declared ``` ```lane cast :: 1; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: `cast` is a predeclared function and cannot be declared ``` Allowed (rule 13c): the same names as a field or an enum variant. This program is built and run by the test suite. ```lane rec R { u8 u8; } enum E { usz, cast } nul main() { } ``` Verified: builds and runs. Exit code 0. No stdout. ## Program, exit code, output ```lane i32 main() { i8 a = 127; a += 1; ret i32(a); } ``` Verified: builds and runs. Exit code -128 (0xffffff80). No stdout. ```lane use io; nul main() { io.print("hello, world\n"); } ``` ## Variables and inferred types A variable declared without a value is zero (integers 0, `bool` false, pointers `nil`, slices empty, arrays all zero). `name := expr;` infers the type from the expression, which must have one. ```lane u64 n = 0; v := x; for v != 0 { ``` ```lane nul main() { a := 1 + 2; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:19: error: the type of this integer is not known here; convert it, as in `u32(1)` ``` ## Constants `NAME :: expr;` at the top of a module or inside a block. Compile-time only, exact on 128 bits while untyped. ```lane STACK :: 64; MEM :: 16; ``` ## Functions, ret ```lane u32 fib(u32 n) { if n < 2 { ret n; } ret fib(n - 1) + fib(n - 2); } ``` Verified: part of a program that builds and runs. For the whole program, exit code 6765. No stdout. ## if, elif, else ```lane i32 pick(i32 n) { i32 r = 9; if n == 1 { r = 1; } elif n == 2 { r = 2; } ret r; } ``` Verified: part of a program that builds and runs. For the whole program, exit code 129. No stdout. `elif` continues an `if`, and `else` is followed only by a block, so a chain has exactly one spelling. `else if` is refused with the message "`else if` is written `elif`". ## Loops: for, brk, nxt `for cond { }` is a while loop, `for { }` runs forever, `for i in a..b { }` runs `a` up to but not including `b`, and `a..=b` includes `b`. `brk` leaves the innermost loop, `nxt` goes to its next iteration. ```lane u32 n = 0; u32 odd = 0; for n < 10 { n += 1; if n % 2 == 0 { nxt; } odd += n; } u32 k = 0; u32 hits = 0; for { k += 1; if k > 20 { brk; } if k % 3 != 0 { nxt; } hits += 1; } ``` Verified: part of a program that builds and runs. For the whole program, exit code 2506. No stdout. ```lane i32 main() { u32 s = 0; for i in u32(1)..=5 { s = s * 10 + i; } ret i32(s); } ``` Verified: builds and runs. Exit code 12345. No stdout. ```lane nul main() { for i in 0..10 { } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:23: error: the type of this integer is not known here; convert it, as in `u32(1)` ``` ## Records and enums A record is a C-layout struct. An enum is a `u32`; its first variant is the zero value. `.name` is a variant whose enum comes from context. ```lane enum Op { push, add, sub, mul, dup, swap, drop, load, store, jmp, jnz, halt } rec Instr { Op op; i32 arg; } ``` ```lane [16]Instr code; code[0].op = .push; code[0].arg = 100; ``` ## match `match subject { pattern, pattern { ... } else { ... } }` on an integer or enum. No fall-through; an integer `match` needs `else`; an enum `match` without `else` must name every variant. Patterns may be ranges `a..=b`. ```lane Class classify(u8 b) { match b { '0'..='9' { ret .digit; } 'a'..='z' { ret .lower; } 'A'..='Z' { ret .upper; } ' ', '\t', '\n', '\r' { ret .space; } '!'..='/', ':'..='@', '['..='`', '{'..='~' { ret .punct; } else { ret .other; } } } ``` ```lane enum C { red, green, blue } nul main() { C c; match c { .red { } } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:19: error: this `match` does not cover the variants `green`, `blue` of `C`; name them or add an `else` arm ``` ## Arrays, slices, strings `[N]T` is `N` values in memory (`N` a constant). `[]T` is a pointer and a length (`s.ptr`, `s.len`, a `usz`). A string literal is a `[]u8` with no terminator. ```lane i32 main() { []u8 s = "hello"; usz total = 0; for i in 0..s.len { total += i; } ret i32(total); } ``` Verified: builds and runs. Exit code 10. No stdout. `x[a..b]` is a sub-slice of the same memory (not copied, not bounds-checked). ## Pointers, cast, slice, size_of `*T` is a pointer, `&place` takes an address, `*p` dereferences, `p + n` moves by `n` elements. `cast(x)` changes a pointer type or converts a pointer to and from `usz`; its target type comes from context. `slice(p, n)` makes a `[]T` from a pointer. ```lane *bool p = &b[0]; *p = true; ``` ```lane [3]i8 a; []u8 raw = slice(cast(&a[0]), 3); ``` ```lane hex(size_of(A)); hex(align_of(A)); ``` Verified: part of a program that builds and runs. For the whole program, exit code 0. Stdout: Lines 1 to 2 of 8. ```text 000000000000000c 0000000000000004 ``` ## Access modes: wr and out ```lane i32 run([]Instr code, wr Vm vm) { ``` ```lane i32 result = run(code, wr vm); ``` ```lane nul set(out Dir d, u32 n) { d = Dir(n); } ``` ```lane rec A { u8 a; } rec B { u8 a; } nul g(wr A a) { } nul main() { A r; g(r); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:4:21: error: parameter `a` of `g` takes `wr`, but the argument has no access mode ``` A parameter without a mode is read-only, and so is everything reached through it: ```lane nul f(u32 a) { a += 1; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:16: error: parameter `a` is read-only ``` ## Several results, variadic parameters, discarding ```lane (f32, bool) find([]u64 keys, u64 key) { for i in 0..keys.len { if keys[i] == key { ret f32(i), true; } } ret 0.0, false; } ``` ```lane pos, ok := find(keys, 7); pos, slots[1] = find(keys, 8); _, ok = find(keys, 9); ``` ```lane f32 sum_all(f32 first, ..[]f32 rest) { ``` ## Function types (no closures) ```lane nul each(wr []f32 v, f32 fn(f32) op) { ``` ## Modules and C imports `use name;` imports `name.ln` next to the file, or the standard module of that name; call its `pub` functions as `name.f(...)`. Only `pub` declarations are visible. `ext` imports (or exports) a C-ABI function; `@lib` names the library. ```lane pub CAP :: 8; HIDDEN :: 3; pub enum Open { a } enum Closed { a } pub rec Pub { u8 a; } rec Priv { u8 a; } ``` Verified: one module of a multi-module program. ```lane use limits; nul main() { limits.Priv p; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:14: error: `limits.Priv` is not `pub` ``` ```lane @lib("kernel32") ext *nul VirtualAlloc(*nul address, usz size, u32 kind, u32 protect); ``` From the standard library module `mem`. It is written in Lane. ## defer, union, generics, tests ```lane defer io.close(f); ``` ```lane union Bits { f32 f; u32 u; } ``` ```lane test "clamp keeps a value inside its range" { io.expect(clamp(5, 0, 3), 3); io.expect(clamp('a', 'b', 'z'), 'b'); } ``` ## Layout, SIMD and threads ```lane rec Body { f32 x; f32 vx; } nul step(wr soa []Body b, f32 dt) { par vec i in 0..b.len { b.x[i] += b.vx[i] * dt; } } ``` `soa []T` stores one array per field; `aos []T` stores records back to back. `f32x4` is a register value, `[4]f32` four floats in memory, `f32xw` the target's widest vector. A `vec` loop must vectorize or the build fails. `par` runs a loop or block across cores and joins. ## Per-target code, hints, float rules ```lane u64 popcnt(u64 x) { when isa >= .bmi2 { ret x86.popcnt64(x); } else when arch == .aarch64 { ret arm.cnt64(x); } else { ``` ```lane @fp(fma, reassoc) f32 dot([]f32 a, []f32 b) { ``` ## Contracts ```lane i32 clamp(i32 v, i32 lo, i32 hi) assume lo <= hi, "lo must not exceed hi"; test (5, 0, 3) == 3, "expected 3 when given 5 for range 0 to 3"; test (-1, 0, 3) == 0; test (7, 3, 3) == 3; test (5, 3, 0) fails; { ``` ## Number types One rule: **arithmetic happens in `f32`, and a value is rounded once when it is stored**, so results are bit-identical on every processor. | Type | Stored as | Means | |---|---|---| | `f32`, `f64` | IEEE binary32, binary64 | the float; strict by default, relaxed per function with `@fp` | | `f16` | IEEE binary16 | the float; each operation is computed in `f32` and rounded once, so it is correctly rounded | | `un8`, `un16` | unsigned integer `n` | `n / (2^k - 1)`, 0.0 to 1.0 | | `sn8`, `sn16` | signed integer `n` | `max(n / (2^(k-1) - 1), -1.0)`, -1.0 to 1.0 (-128 means -1.0) | | `bf16`, `f8e4m3`, `f8e5m2` | 16-bit and 8-bit floats | machine-learning data, converted with the same rule | - From a float to `un` or `sn`: clamp to the range, round to nearest even, NaN gives 0. - `packed` arrays store these types at their real width (`un8` is one byte per element). - Example: a vertex normal as 3 x `sn8` and a colour as 4 x `un8` take 7 bytes in a record. ## Keywords | Group | Keywords | |---|---| | Declarations | `fn` `rec` `enum` `union` `use` `pub` `ext` | | Layout | `soa` `aos` | | Control | `if` `elif` `else` `for` `in` `match` `brk` `nxt` `ret` `defer` | | Data-parallel | `vec` `par` `wr` `out` | | Compile-time | `when` | | Tooling | `test` `bench` | | Escape hatch | `asm` | | Literals | `true` `false` `nil` | Reserved and never usable as identifiers: `ct` `try`. ## Operators, loosest first | Level | Operators | Note | |---|---|---| | 0 | `..` `..=` | do not chain | | 1 | `\|\|` | | | 2 | `&&` | | | 3 | `==` `!=` `<` `<=` `>` `>=` | do not chain | | 4 | `+` `-` `\|` `^` | | | 5 | `*` `/` `%` `<<` `>>` `&` | | Bitwise operators bind tighter than comparisons, so `a & b == c` means `(a & b) == c`: ```lane i32 main() { i32 a = 6; if a & 3 == 2 { ret 1; } ret 2; } ``` Verified: builds and runs. Exit code 1. No stdout. Comparison operators do not chain. Unary `-` `!` `~` `*` `&` bind tighter than any binary operator. `a op= b` needs a variable of integer type. ## More refusals worth knowing ```lane nul main() { u32 a = 1; if true { a := true; } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:35: error: `a` is already declared ``` ```lane nul main() { if 1 { } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:17: error: expected `bool`, found an integer ``` ```lane nul main() { u8 a = -1; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:21: error: `-1` does not fit in `u8` ``` ```lane N :: u8(1) + u16(1); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:12: error: `+` needs operands of the same type, found `u8` and `u16` ``` ```lane nul main() { brk; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: `brk` outside a loop ``` More in the [error reference](https://lane.trisgram.com/docs/agents/errors.md) and [verified examples](https://lane.trisgram.com/docs/agents/examples.md). --- # Lane documentation > A syntax tour of Lane for people, and a set of plain-Markdown pages for agents. Lane is a data-oriented systems language. This tour follows the language specification and shows only code that really exists: programs from the compiler's test suite, the standard library, and syntax examples that the parser accepts. ```lane use io; nul main() { io.print("hello, world\n"); } ``` ## Verified examples A program that the compiler's test suite builds is marked "Verified: builds and runs". The page shows the standard output and exit code the suite expects, read from the test when this site is built, so the claim is checked at every build. A program that the compiler must refuse is marked "Verified" with the compiler's message. Which constructs the current compiler accepts is listed, with a date, in the Status section of the [agent docs](https://lane.trisgram.com/docs/agents.md). The [roadmap](https://lane.trisgram.com/roadmap.md) has what comes next. ## The tour 1. [Types and literals](https://lane.trisgram.com/docs/types.md): scalars, wrapping arithmetic, literals that take their type from context, no implicit conversions. 2. [Declarations and functions](https://lane.trisgram.com/docs/declarations.md): type-first declarations, access modes (`wr`, `out`), several results, variadic parameters, function types. 3. [Statements and control flow](https://lane.trisgram.com/docs/statements.md): `if`, the three kinds of `for`, `brk`, `nxt`, `ret`, `defer`, scopes. 4. [Records, enums and match](https://lane.trisgram.com/docs/records-enums.md): C layout, copying, enums as `u32`, exhaustive `match`. 5. [Constants](https://lane.trisgram.com/docs/constants.md): exact compile-time arithmetic, typed and untyped constants. 6. [Memory](https://lane.trisgram.com/docs/memory.md): pointers, slices, arrays, arenas, and why there is no `new`. 7. [Data layout, SIMD and threads](https://lane.trisgram.com/docs/layout-simd.md): `soa`, `aos`, vector types, `vec`, `par`. 8. [Per-ISA code, hints and floats](https://lane.trisgram.com/docs/targets-hints.md): `when`, hints, `@fp`. 9. [Contracts](https://lane.trisgram.com/docs/contracts.md): `assume` and examples. 10. [Modules and the standard library](https://lane.trisgram.com/docs/modules.md): `use`, `pub`, `ext`, `io`, `fmt`, `mem`, `os`, `bufio`. 11. [The `lane` command and its tests](https://lane.trisgram.com/docs/tooling.md). ## For agents The pages under [For agents](https://lane.trisgram.com/docs/agents.md) are written to be read by a program: plain Markdown, no JavaScript needed, with a one-page cheat sheet of the rules that are easy to get wrong, the verified examples and the error reference. `/llms.txt` indexes them and `/llms-full.txt` is the whole reference in one file. Every page here also has a Markdown twin: add `.md` to its path. --- # Types and literals > Scalar types, wrapping arithmetic, literals that take their type from context, and why nothing converts implicitly. ## Scalars The scalar types are `i8` `i16` `i32` `i64` `u8` `u16` `u32` `u64` `isz` `usz` `f16` `f32` `f64` `bool`. `nul` is the empty type: the return type of a function that returns nothing, and the pointee of an untyped pointer (`*nul`). The names of types are ordinary identifiers that the compiler predeclares, so adding a type never changes the lexer. `isz` and `usz` are distinct types from `i64` and `u64`, so code that mixes them does not silently depend on the pointer width. A `bool` occupies one byte that is 0 or 1. ## Integer arithmetic wraps Arithmetic is two's complement and wraps: `+`, `-`, `*` and unary `-` keep the low bits of the exact result. Overflow is never an error and never undefined. ```lane i32 main() { i8 a = 127; a += 1; ret i32(a); } ``` Verified: builds and runs. Exit code -128 (0xffffff80). No stdout. ```lane i32 main() { u8 a = 0; a -= 1; ret i32(a); } ``` Verified: builds and runs. Exit code 255. No stdout. `/` truncates toward zero and `%` has the sign of the dividend; both are unsigned for unsigned types. ```lane i32 main() { i32 a = -7; ret a / 2; } ``` Verified: builds and runs. Exit code -3 (0xfffffffd). No stdout. ```lane i32 main() { i32 a = -7; ret a % 2; } ``` Verified: builds and runs. Exit code -1 (0xffffffff). No stdout. Division and remainder by zero are not checked. The processor's divide fault stops the program; on Windows the exit code is `0xc0000094`. ```lane i32 main() { u32 a = 5; u32 b = 0; ret i32(a / b); } ``` Verified: builds and runs. Exit code -1073741676 (0xc0000094). No stdout. `>>` copies the sign of a signed value and shifts zeros into an unsigned one. The shift count is taken modulo the width of the type, so shifting a `u8` by 8 leaves it unchanged. ```lane i32 main() { u8 a = 1; u8 n = 8; ret i32(a << n); } ``` Verified: builds and runs. Exit code 1. No stdout. ## Literals take their type from where they are used An integer literal has no type of its own. It takes the type of the other operand, or the type the context expects, and it must fit. There are no literal suffixes: a number that runs into identifier bytes (`12abc`, `1.5f`) is one error token. Digits may be separated by `_`, and there are hexadecimal (`0xff`) and binary (`0b1010`) forms. ```lane i32 main() { u8 a = 200; u8 b = a + 100; ret i32(b); } ``` Verified: builds and runs. Exit code 44. No stdout. When both operands are literals they take the type the context expects, each must fit, and the result wraps: ```lane i32 main() { u8 c = 200 + 100; ret i32(c); } ``` Verified: builds and runs. Exit code 44. No stdout. Where nothing gives a type, that is an error, and the message says how to give one: ```lane nul main() { a := 1 + 2; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:19: error: the type of this integer is not known here; convert it, as in `u32(1)` ``` A literal that does not fit is an error as well, and no negative literal fits in an unsigned type: ```lane nul main() { u8 a = -1; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:21: error: `-1` does not fit in `u8` ``` A character literal is an integer, the value of its one byte, and takes its type from where it is used: ```lane i32 main() { u8 c = 'a'; ret i32(c); } ``` Verified: builds and runs. Exit code 97. No stdout. ```lane i32 main() { ret 'a' + 1; } ``` Verified: builds and runs. Exit code 98. No stdout. A string literal is a `[]u8` of its bytes with no terminator; its escapes are `\n` `\t` `\r` `\0` `\\` `\"` `\'` and `\xNN`. Source files are ASCII: any byte other than tab, line feed, carriage return and 0x20 to 0x7e is a lexical error, even inside a string or a comment. Write other bytes as `\xNN`. ## No implicit conversions There are no implicit conversions between types. `u32(x)` converts between integer types: narrowing keeps the low bits, widening extends by the sign of the source type. A `bool` converts to any integer type as the 0 or 1 it is; there is no conversion from an integer to `bool`, so write `x != 0`. ```lane i32 main() { i8 a = -7; i8 b = 2; ret i32(a / b) * 10 + i32(a % b); } ``` Verified: builds and runs. Exit code -31 (0xffffffe1). No stdout. Mixing types in one operator is an error, in constants as well as in code: ```lane N :: u8(1) + u16(1); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:12: error: `+` needs operands of the same type, found `u8` and `u16` ``` The condition of `if` and `for` is a `bool`; an integer is not a condition. ```lane nul main() { if 1 { } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:17: error: expected `bool`, found an integer ``` ## Operators `+ - * / % & | ^ << >>` take two operands of the same integer type and give that type. Comparisons give a `bool`. `&&` and `||` evaluate the right operand only when the left does not decide. Operands and arguments are evaluated left to right. Operators from loosest to tightest: | Level | Operators | Note | |---|---|---| | 0 | `..` `..=` | do not chain | | 1 | `\|\|` | | | 2 | `&&` | | | 3 | `==` `!=` `<` `<=` `>` `>=` | do not chain | | 4 | `+` `-` `\|` `^` | | | 5 | `*` `/` `%` `<<` `>>` `&` | | Bitwise operators bind tighter than comparisons, so `a & b == c` means `(a & b) == c`. Comparisons do not chain. Unary `-` `!` `~` `*` and `&` bind tighter than any binary operator. ```lane i32 main() { i32 a = 6; if a & 3 == 2 { ret 1; } ret 2; } ``` Verified: builds and runs. Exit code 1. No stdout. ## Number types Besides the integers, Lane has a family of number types for fractional values. They are all described by one rule: **arithmetic happens in `f32`, and the result is rounded once when it is stored.** Because the rounding is one exact step, every operation gives bit-identical results on every processor. | Type | Stored as | Value | Range | |---|---|---|---| | `f32` | IEEE binary32 | the stored float | | | `f64` | IEEE binary64 | the stored float | | | `f16` | IEEE binary16 | the stored float | | | `un8`, `un16` (unorm) | unsigned 8 or 16-bit integer `n` | `n / (2^k - 1)`, with `k` the bit count (8 or 16) | 0.0 to 1.0 | | `sn8`, `sn16` (snorm) | signed 8 or 16-bit integer `n` | `max(n / (2^(k-1) - 1), -1.0)` | -1.0 to 1.0 | | `bf16`, `f8e4m3`, `f8e5m2` | 16-bit and 8-bit floats for machine-learning data | the stored float | by format | - **`f32` and `f64`** are IEEE floats. They are strict by default: operations happen in source order and nothing is fused, so the bits are the same on every target. A function relaxes this with `@fp` (see [Per-ISA code, hints and floats](https://lane.trisgram.com/docs/targets-hints.md)). - **`f16`** is IEEE binary16. Every operation is computed in `f32` and rounded once, so it is correctly rounded and gives identical bits on every processor. - **`un8` and `un16`** (unorm) store an integer `n` that means `n / (2^k - 1)`, a value from 0.0 to 1.0. Converting from a float clamps to 0.0..1.0 first, then rounds to nearest even; a NaN gives 0. - **`sn8` and `sn16`** (snorm) store a signed integer `n` that means `max(n / (2^(k-1) - 1), -1.0)`, a value from -1.0 to 1.0. The most negative integer, -128 for `sn8`, means -1.0, the same value as -127. Converting from a float clamps to -1.0..1.0, rounds to nearest even, and turns a NaN into 0. - **`bf16`, `f8e4m3` and `f8e5m2`** are for machine-learning data. They follow the same rule: a conversion to or from `f32` rounds once, to nearest even, and gives the same bits on every processor. - **`packed` arrays** store these types at their real width: an array of `un8` takes one byte per element, an array of `f16` two. A vertex shows why they exist. A record with a normal and a colour: | Field | Type | Size | Holds | |---|---|---|---| | `normal` | 3 x `sn8` | 3 bytes | a direction, each component from -1.0 to 1.0 | | `color` | 4 x `un8` | 4 bytes | red, green, blue and alpha, each from 0.0 to 1.0 | That is 7 bytes for a normal and a colour, where `f32` components would need 28. Code that reads the fields sees `f32` values; the conversions are the rules above. ## Vectors and function types Vector types are written `x`. `f32x4` is one SIMD register holding four floats and is a value; `[4]f32` is four floats in memory; `f32xw` has as many lanes as the target's widest vector (16 with AVX-512, 8 with AVX2, 4 with NEON or SIMD128). ```lane f32 dot4(f32x4 a, f32x4 b) { ret hsum(a * b); } ``` A function type puts the return type first, like a function declaration: `f32 fn(f32, f32)`. It is a code address and nothing else; there are no closures, so a callback that needs state takes it as a parameter. ```lane f32 fold([]f32 v, f32 init, f32 fn(f32, f32) op) { ``` --- # Declarations and functions > Type-first declarations, functions, the access modes wr and out that are repeated at the call, several results, variadic parameters and function types. ## Types go first Declarations put the type first: `type name`. That holds for variables, fields, parameters and functions. Modifiers go in front of the type, never on the name: `*u8 p`, `[]f32 s`, `[4]f32 v`. A function is `returnType name(params) { }`; the return type is always written, and a function that returns nothing returns `nul`. ```lane u32 fib(u32 n) { if n < 2 { ret n; } ret fib(n - 1) + fib(n - 2); } ``` Verified: part of a program that builds and runs. For the whole program, exit code 6765. No stdout. One file is one module. Declarations may appear in any order and there are no headers or forward declarations. A program starts at `main` in its root file, declared `nul main()` or `i32 main()`; an `i32` result is the process exit code. A variable declared without a value is zero: integers 0, `bool` false, pointers `nil`, slices empty, arrays all zero. `name := expr;` declares a variable whose type comes from the expression, which must have one. ```lane u64 n = 0; v := x; for v != 0 { ``` The example is a syntax example; `v` takes the type of `x`. The inferred form `a := 1;` is refused, because a bare literal has no type. See [Types and literals](https://lane.trisgram.com/docs/types.md). ## Access modes: wr and out A parameter has one of three access modes. With none it is read-only: it cannot be assigned, an element or field of it cannot be assigned, and its address cannot be taken. `wr` makes it readable and writable. `out` makes it write-only: it must be assigned on every path before the function returns, and the caller may pass a variable that has no value yet. The call repeats the mode, so a reader sees at the call site which arguments are written. ```lane i32 run([]Instr code, wr Vm vm) { ``` ```lane i32 result = run(code, wr vm); ``` An `out` parameter: ```lane nul set(out Dir d, u32 n) { d = Dir(n); } ``` The checker enforces the modes. A read-only parameter cannot be written: ```lane nul f(u32 a) { a += 1; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:16: error: parameter `a` is read-only ``` The mode written at the call must equal the parameter's: ```lane rec A { u8 a; } rec B { u8 a; } nul g(wr A a) { } nul main() { A r; g(r); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:4:21: error: parameter `a` of `g` takes `wr`, but the argument has no access mode ``` ```lane rec A { u8 a; } rec B { u8 a; } nul g(A a) { } nul main() { A r; g(wr r); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:4:24: error: parameter `a` of `g` takes no access mode, but the argument has `wr` ``` An `out` parameter that can reach the end of the function unassigned is an error: ```lane nul f(u8 x, out u32 y) { match x { 1 { y = 1; } else { } } } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: `out` parameter `y` is not assigned on every path to the end of `f` ``` Two arguments of one call may not name the same storage if one of them is written: ```lane rec A { u8 a; } rec B { u8 a; } nul g(A a, wr u8 v) { } nul main() { A r; g(r, wr r.a); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:4:28: error: `r` is named by two arguments of one call, and one of them is passed as `wr` ``` How an argument travels: a slice without a mode or with `wr` is passed as a pointer and a length, so `wr` only makes its elements writable. A record or an array is passed by its address in every mode and nothing is copied. Any other type is passed by value without a mode and by address with `wr` or `out`. Section 5.4 of the specification has every rule, including the aliasing check. ## Several results A return type may be a list of two or more types. The function returns the values in registers, `ret a, b;` returns them, and a call with several targets receives them. A target `_` discards a value. ```lane (f32, bool) find([]u64 keys, u64 key) { for i in 0..keys.len { if keys[i] == key { ret f32(i), true; } } ret 0.0, false; } ``` ```lane pos, ok := find(keys, 7); pos, slots[1] = find(keys, 8); _, ok = find(keys, 9); slots[0], _ = find(keys, 10); r, g, b := split(0x00ff8040); ``` ## Variadic parameters The last parameter may be written `..[]T name`: the function accepts any number of trailing arguments of type `T`. The compiler builds the array on the caller's stack and passes a slice, so the function's type is the same as one with a plain `[]T` parameter. `f(..xs)` passes an existing slice. ```lane f32 sum_all(f32 first, ..[]f32 rest) { ``` ```lane a = sum_all(1.0, 2.0, 3.0); b = sum_all(0.0, ..xs); ``` ## Function types A function type puts the return type first: `f32 fn(f32, f32)`. It is a code address and nothing else. There are no closures; a callback that needs state takes it as a parameter. An indirect call inside a `vec` loop is a compile error. A function type carries the access mode of each parameter. ```lane nul each(wr []f32 v, f32 fn(f32) op) { ``` ```lane nul hooks(nul fn(wr []f32, out u32) visit, (f32, bool) fn(u64) probe) { } ``` ## Attributes An attribute is `@name` or `@name(args)` in front of a declaration or a parameter: `@inline`, `@hot`, `@align(64)`, `@range(lo, hi)`, `@fp(...)`, `@lib("kernel32")`. See [Per-ISA code, hints and floats](https://lane.trisgram.com/docs/targets-hints.md). --- # Statements and control flow > Semicolons, scopes without shadowing, if, the three kinds of for, brk, nxt, ret, defer and the check that every path returns. ## Semicolons A semicolon terminates a statement. Newlines are whitespace and never terminate anything, so a statement may span lines freely. - Simple statements end with `;`: variable declarations, assignments, calls, `ret`, `brk`, `nxt`, `defer`. This includes the last statement of a block. - Record and union fields end with `;`. - Declarations without a body end with `;`: `use`, constants, and `ext` imports. - Anything that ends with a `}` block takes no semicolon: functions, `rec`, `enum`, `union`, `if`, `for`, `vec`, `par`, `match`, `when`, `asm`, `test`, `bench`. - Enum variants, parameters and arguments are separated by commas; a trailing comma is allowed. An expression statement must be a call. `a + 1;` and `true;` are errors because they do nothing. ## if The condition is a `bool` and needs no parentheses, because `{` never continues an expression. ```lane i32 pick(i32 n) { i32 r = 9; if n == 1 { r = 1; } elif n == 2 { r = 2; } ret r; } ``` Verified: part of a program that builds and runs. For the whole program, exit code 129. No stdout. ## for There are three loops, all written `for`. - `for cond { }` runs while the `bool` condition holds. - `for { }` runs until a `brk` or a `ret`. - `for i in a..b { }` runs `i` from `a` up to but not including `b`; `a..=b` includes `b`, which may be the largest value of the type. ```lane u32 n = 0; u32 odd = 0; for n < 10 { n += 1; if n % 2 == 0 { nxt; } odd += n; } u32 k = 0; u32 hits = 0; for { k += 1; if k > 20 { brk; } if k % 3 != 0 { nxt; } hits += 1; } ``` Verified: part of a program that builds and runs. For the whole program, exit code 2506. No stdout. `brk` leaves the innermost loop. `nxt` starts its next iteration: the next value of a range, or the condition of `for cond { }` again. Outside a loop both are errors. ```lane nul main() { brk; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: `brk` outside a loop ``` The two bounds of a range are integers of the same type, each evaluated once, `a` then `b`, before the first iteration. A literal bound takes the type of the other bound; two literal bounds give no type and are an error, so write `u32(0)..10`. ```lane i32 main() { u32 s = 0; for i in u32(1)..=5 { s = s * 10 + i; } ret i32(s); } ``` Verified: builds and runs. Exit code 12345. No stdout. ```lane nul main() { for i in 0..10 { } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:23: error: the type of this integer is not known here; convert it, as in `u32(1)` ``` A range that starts past its end runs no iteration. The loop variable has the type of the bounds, is visible in the body only and is read-only. ```lane nul main() { for i in u32(0)..3 { i = 1; } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:35: error: loop variable `i` is read-only ``` The bounds are evaluated once, which a program can show with output: ```lane u32 bound([]u8 name, u32 v) { io.print(name); ret v; } nul main() { u32 n = 3; for i in bound("a", 0)..bound("b", n) { n += 10; io.print("."); } for i in bound("c", 1)..=bound("d", 2) { io.print(":"); } for i in bound("e", 2)..bound("f", 2) { io.print("!"); } io.print("\n"); } ``` Verified: part of a program that builds and runs. For the whole program, exit code 0. Stdout: ```text ab...cd::ef ``` Iterating over a slice, `for c in text`, appears in a syntax example, but the specification does not define it (it says only "over a range or sequence"), and the compiler refuses a `for ... in` over anything but a range. ## Scopes Every `{ }` is a scope: a function body, a branch, a loop body, or a block on its own. A variable is visible from its declaration to the end of its block. A name that is visible, parameters and loop variables included, cannot be declared again: there is no shadowing. After its block ends the name is free. ```lane nul main() { u32 a = 1; if true { a := true; } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:35: error: `a` is already declared ``` ```lane nul main() { for i in u32(0)..3 { } u32 b = i; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:45: error: unknown name `i` ``` ## ret, and every path must return `ret value;` leaves the function; in a function that returns `nul` write `ret;`. A function that returns a value must end every path with `ret`. The check looks at the shape of the code and never at the value of a condition. A statement can be passed unless it is a `ret`, `brk` or `nxt`; an `if` with an `else` where neither branch can be passed; a `for { }` that contains no `brk` of its own; or a block containing such a statement. So `for true { }` can be passed and `for { }` cannot. ```lane i32 f(bool c) { for { if c { ret 1; } } } nul main() { } ``` Verified: builds and runs. Exit code 0. No stdout. ```lane nul main() { } i32 g() { for { brk; } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:1: error: `g` returns `i32`, but not every path ends with `ret` ``` ```lane i32 main() { if true { ret; } ret 0; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:24: error: `main` returns `i32`; `ret` needs a value ``` ## match `match` is covered with enums in [Records, enums and match](https://lane.trisgram.com/docs/records-enums.md). It takes part in the return and `out` analyses as if it were an `if` and `elif` chain. ## defer `defer` runs a statement at scope exit, for the rare owned resource. Memory itself comes from arenas, not from `defer`; see [Memory](https://lane.trisgram.com/docs/memory.md). ```lane bool load([]u8 path) { f := io.open(path); if f == nil { ret false; } defer io.close(f); ret true; } ``` The functions `io.open` and `io.close` here stand for any resource functions; they are illustrative. ## Compound assignment `a op= b` needs a variable of an integer type and a `b` of that type. It evaluates `b`, then reads `a` and stores `a op b`: in `a[i] += f()`, a change that `f` makes to `a[i]` is seen. --- # Records, enums and match > C-layout records, copying and modes, enums stored as u32, unchecked conversion, and match with exhaustiveness. ## Records `rec Name { type field; ... }` declares a type. The layout is the C layout: fields in declaration order, each at the next multiple of its own alignment, the size of the record rounded up to the largest alignment of any field. Sizes and alignments are 1 for `bool` and the 8-bit types, 2 for the 16-bit types, 4 for the 32-bit types and enums, 8 for the 64-bit types, `isz`, `usz`, pointers and slices (a slice is 16 bytes: pointer, then length). An array has the alignment of its element. A record has at least one field and at most 1 GiB. Padding bytes are zero in a variable that was declared without a value. `size_of(T)` and `align_of(T)` give the layout as untyped constants. For `rec A { u8 a; u32 b; u8 c; }` the size is 12 and the alignment is 4: ```lane hex(size_of(A)); hex(align_of(A)); ``` Verified: part of a program that builds and runs. For the whole program, exit code 0. Stdout: Lines 1 to 2 of 8. ```text 000000000000000c 0000000000000004 ``` `r.f` is the field `f` of the record `r`. It is a place: it can be read, assigned, assigned with an operator, and have its address taken. Fields chain with elements (`xs[i].f`, `r.arr[i]`). On a pointer to a record `p.f` reads the pointer once and takes the field of what it points at. ```lane rec Instr { Op op; i32 arg; } rec Vm { [STACK]i32 stack; [MEM]i32 mem; usz sp; usz pc; u64 steps; } ``` ```lane [16]Instr code; code[0].op = .push; code[0].arg = 100; ``` Rules to know: - A record variable without an initial value is zero. `a = b;`, `Rec a = b;` and `a := b;` copy all the bytes of `b`, arrays inside it included. Records are not compared: compare their fields. - A record contains itself only through a pointer or a slice. - A record is passed by its address in every mode and is read-only without a mode: no field or element reached through it can be assigned or have its address taken (this does not extend through a pointer field). - A function cannot return a record yet; use an `out` parameter. A record cannot cross the C ABI; pass a pointer. There is no record literal. ```lane rec A { A a; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:11: error: record `A` contains itself; a field of its own type must be a pointer or a slice ``` ```lane rec A { u8 a; } rec B { u8 a; } nul g(A a, wr u8 v) { } nul main() { A r; g(r, wr r.a); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:4:28: error: `r` is named by two arguments of one call, and one of them is passed as `wr` ``` ```lane rec A { u32 x; [2]u32 arr; } nul f(A r) { r.x = 1; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:15: error: parameter `r` is read-only; its fields cannot be assigned ``` ```lane rec A { u32 x; } pub A f() { } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:5: error: not supported by the stage-0 backend yet: returning a record; use an `out` parameter instead ``` ```lane nul main() { u32 a = 1; u32 b = a.x; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:34: error: `u32` has no field `x` ``` `union Name { type field; ... }` declares a type whose fields share one address. ## Enums `enum Name { a, b, c }` declares a type whose values are 0, 1, 2 and so on, in the order written. An enum is stored as a `u32`. The zero value, which a variable without an initial value has, is the first variant. `Name.a` is a value wherever a value is expected, and `.a` wherever the context gives the enum: a declared type, an assignment, an argument, a `ret`, the other side of `==` or `!=`, a pattern. `==` and `!=` compare two values of the same enum. Nothing else is defined on enums: not `<`, not `+`. `u32(e)` gives the number of the variant. `Name(n)` makes an enum from an integer, and it is unchecked: a value that names no variant is possible, and this is the only way to get one. ```lane enum Dir { north, east, south, west } rec Ship { u8 tag; Dir facing; } Dir next(Dir d) { if d == .west { ret .north; } ret Dir(u32(d) + 1); } nul set(out Dir d, u32 n) { d = Dir(n); } nul main() { Dir d; hex(u64(u32(d))); d = .south; hex(u64(u32(d))); hex(u64(u32(Dir.west))); hex(u64(u32(Dir.north))); ``` Verified: part of a program that builds and runs. For the whole program, exit code 0. Stdout: Lines 1 to 4 of 29. ```text 0000000000000000 0000000000000002 0000000000000003 0000000000000000 ``` The four lines of output are the four `hex` calls: the zero value (0), `.south` (2), `Dir.west` (3), `Dir.north` (0). ```lane enum E { a } nul main() { E e = .b; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:20: error: `E` has no variant `b` ``` ```lane enum E { a } nul main() { u32 x = .a; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:22: error: expected `u32`, found an enum value ``` ## match `match subject { pattern, pattern { ... } ... else { ... } }` takes an integer or an enum. The subject is computed once. The arms are tested in the order written and the first that matches runs; there is no fall-through, and each arm is its own scope. A pattern is a constant expression of the subject's type. For an integer subject a pattern may also be a range, `a..b` (up to but not including `b`) or `a..=b`. For an enum the patterns are variants. ```lane enum Class { digit, lower, upper, space, punct, other } Class classify(u8 b) { match b { '0'..='9' { ret .digit; } 'a'..='z' { ret .lower; } 'A'..='Z' { ret .upper; } ' ', '\t', '\n', '\r' { ret .space; } '!'..='/', ':'..='@', '['..='`', '{'..='~' { ret .punct; } else { ret .other; } } } nul main() { [6]u32 counts; u64 h = 0; for b in u32(0)..256 { Class c = classify(u8(b)); counts[usz(u32(c))] += 1; h = h * 7 + u64(u32(c)) + 1; } for i in usz(0)..6 { hex(u64(counts[i])); } hex(h); hex(u64(u32(classify('a')))); hex(u64(u32(classify('`')))); hex(u64(u32(classify(127)))); } ``` Verified: part of a program that builds and runs. For the whole program, exit code 0. Stdout: ```text 000000000000000a 000000000000001a 000000000000001a 0000000000000004 0000000000000020 000000000000009e 9509af2cfa3c7520 0000000000000001 0000000000000004 0000000000000005 ``` Exhaustiveness: an integer `match` needs an `else`; an enum `match` without `else` must name every variant, and the error lists the ones that are missing. ```lane enum C { red, green, blue } nul main() { C c; match c { .red { } } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:19: error: this `match` does not cover the variants `green`, `blue` of `C`; name them or add an `else` arm ``` ```lane nul main() { u8 x = 1; match x { } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:24: error: a `match` on an integer needs an `else` arm ``` A value matched by two patterns, or by a range and another pattern, is an error, reported at the later pattern: ```lane nul main() { u8 x = 1; match x { 5 { } 1..10 { } else { } } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:40: error: the range 1..10 overlaps an earlier pattern at 5 ``` An enum `match` without `else` that is reached by a value naming no variant (made with `Name(n)`) stops the program with an illegal-instruction fault. A `match` takes part in the analyses of returns and `out` parameters as if it were an `if` and `elif` chain: a function whose every path ends in an arm that returns needs no `ret` after it. A `match` is a chain of comparisons, where a range is one subtraction and one unsigned comparison; jump tables are a later optimization. --- # Constants > NAME :: expr; constants, exact compile-time arithmetic on 128 bits, typed and untyped constants, and dependency order. ## Declaring a constant `NAME :: expr;` declares a constant at the top of a module or, as a statement, inside a block. A constant is never assigned. Its value is an integer, a `bool` or an enum value, computed by the compiler from literals, other constants, enum variants, the operators and the conversions `u8(x)` and `Color(n)`, and `size_of(T)` and `align_of(T)`. A call to any other function, a variable, a string, an index or an address is an error. ```lane STACK :: 64; MEM :: 16; ``` A constant is the length of an array, a `match` pattern, or a value of its own: ```lane rec Vm { [STACK]i32 stack; [MEM]i32 mem; usz sp; usz pc; u64 steps; } ``` ```lane N :: f(); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:7: error: this is not a constant expression ``` ```lane N :: 3; nul main() { N = 4; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:14: error: constant `N` cannot be assigned ``` ## Order does not matter A module-level constant may use constants and types declared later in the file or in an imported module. Constants and records are evaluated in dependency order, however long the chain: a hundred thousand constants, each defined by the next, compile. A dependency cycle is an error whatever the values, and it is reported once, naming the declarations on the way. ```lane A :: B; B :: A; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: constant `A` is defined in terms of itself through `B` ``` ## Untyped and typed constants An integer constant made only of literals and other untyped constants is **untyped**: its arithmetic is exact on the integers from -2^127 to 2^127 - 1, so `(1 << 64) - 1` is the largest `u64`. An operation whose exact result is outside that range is an error, with the operands in the message. Nothing wraps and nothing is approximated. ```lane N :: 1 << 127; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:8: error: the constant `1 << 127` is too large to compute ``` Where an untyped constant is used it behaves like a literal: it takes the integer type the context expects and must fit in it. ```lane N :: 300; nul main() { u8 x = N; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:21: error: constant `N` = 300 does not fit in `u8` ``` A constant made with a conversion (`u8(200)`) is **typed**: it has that type everywhere, and an operation on typed constants wraps to the type's width exactly as it does at run time (`u8(200) + u8(100)` is 44). Both operands typed must have the same type. ```lane N :: u8(1) + u16(1); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:12: error: `+` needs operands of the same type, found `u8` and `u16` ``` Division by zero in a constant is an error, not a fault: ```lane N :: 10 / 0; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:9: error: division by zero in a constant expression ``` ## Constants and visibility `size_of(T)` and `align_of(T)` take a type name and give an untyped integer constant. A constant of a `pub` declaration is reached from another module as `module.NAME`; one that is not `pub` is refused. ```lane use limits; N :: limits.HIDDEN + 1; ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:12: error: `limits.HIDDEN` is not `pub` ``` The names `size_of`, `align_of`, `cast`, `slice`, `nul` and those of the scalar types cannot be declared as anything that is in scope by its own name: a function, a constant, a record, an enum, a parameter, a variable or a loop variable. ```lane i8 :: 1; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: `i8` is a predeclared type and cannot be declared ``` Arithmetic in a runtime expression on constants is not folded: `N * 2` in `u8 c = N * 2;` is a literal operation, so each operand must fit `u8` and the product wraps. --- # Memory > Arrays, slices, pointers, cast and slice, and arenas. There is no new, no global heap and no destructor. ## What there is, and what there is not There is no `new` or `destroy`, no global heap and no destructors. Memory comes from arenas, which are library values passed explicitly, and is released a whole arena at a time. Data lives in tables and refers to other data by integer handle, not by pointer. Pointers exist for FFI and for slices inside a kernel. `defer` runs a statement at scope exit for the rare owned resource. Nothing allocates, bounds-checks or copies behind the programmer's back. ## Arrays `[N]T` is `N` values of type `T` back to back. `N` is a constant expression of at least 1 and `T` is any type but `nul`. `a.len` is `N`, a `usz`. Elements are stored at the type's real size and natural alignment. An array is memory and is never copied: assigning a whole array, initializing one from another, comparing two and returning one are all refused. Passing an array to a function passes its address, in every mode. A variable declared without a value is zero, arrays included, and the declaration zeroes it every time it runs. ```lane [300000]u8 a; a[0] = 3; a[299999] = 4; ret i32(a[0]) * 10 + i32(a[299999]) + i32(a.len); ``` The program that contains these lines builds, runs and exits with code 300034: `3 * 10 + 4 + 300000`. A function's frame holds its variables, and a frame of a page or more is probed page by page in the function's first instructions so Windows commits the stack as the frame grows. There are no bounds checks: an index outside the array reads or writes whatever memory is there. The index is a `usz`; a literal takes that type. ## Slices A slice `[]T` is a pointer and a length: `s.ptr` is a `*T`, `s.len` a `usz`. A string literal is a `[]u8` of its bytes with no terminator, in read-only memory. An array converts to a slice of its elements wherever a slice is expected; it is the one implicit conversion, and the slice is a view of the same memory, never a copy. ```lane i32 main() { []u8 s = "hello"; usz total = 0; for i in 0..s.len { total += i; } ret i32(total); } ``` Verified: builds and runs. Exit code 10. No stdout. `x[a..b]` and `x[a..=b]` are the slice of the elements from `a` up to `b`, in the same memory. The bounds are unchecked: the length is `b - a` computed with wrap-around. A sub-slice is a value, not a place: it cannot be assigned or have its address taken. ## Pointers `*T` is a pointer. `&place` is the address of a variable, an element or a dereference, `*p` reads the pointee, and `*p = v` writes it. The pointee is read and written at its own size. ```lane *bool p = &b[0]; *p = true; ``` For `p` of type `*T` and a `usz` `n`, `p + n` and `p - n` move by `n` elements, and `p - q` is the number of elements between two pointers of the same type. A pointer cannot be indexed; `slice(p, n)` makes a slice of it first. The address of a local is valid until its function returns and nothing checks that. `cast(x)` converts a pointer to a pointer of another type, a pointer to a `usz` and a `usz` to a pointer, without changing a bit. Its target type is the one the context expects: a declared variable type, a parameter, a return type, the other side of an assignment or of `==`. `slice(p, n)` makes the `[]T` of `n` elements that start at the `*T` `p`. ```lane [3]i8 a; []u8 raw = slice(cast(&a[0]), 3); ``` `nil` is a pointer of whatever pointer type the context wants. Reads and writes through a pointer need not be aligned. ## Arenas An arena is a block of memory handed out in order. `mem.Arena` is a record in the standard library: ```lane pub rec Arena { *u8 base; usz used; usz cap; } ``` From the standard library module `mem`. It is written in Lane. `alloc` returns the next `size` bytes, aligned as asked, all zero, or an empty slice when they do not fit. A failed call changes nothing. It is ordinary Lane: arithmetic on addresses with `cast`, and `slice` to make the result. ```lane pub []u8 alloc(wr Arena a, usz size, usz align) { []u8 none; if size == 0 || align == 0 || (align & (align - 1)) != 0 { ret none; } usz base = cast(a.base); usz pad = (-(base + a.used)) & (align - 1); if pad > a.cap - a.used { ret none; } usz start = a.used + pad; if size > a.cap - start { ret none; } a.used = start + size; ret slice(a.base + start, size); } ``` From the standard library module `mem`. It is written in Lane. `pad` is the number of bytes to skip so that the start of the allocation is a multiple of `align`. An arena takes its memory from the system (`VirtualAlloc` on Windows), and `release` gives it back: ```lane pub nul release(wr Arena a) { if a.base != nil { VirtualFree(cast(a.base), 0, MEM_RELEASE); } a.base = nil; a.used = 0; a.cap = 0; } ``` From the standard library module `mem`. It is written in Lane. A function that needs memory takes the arena as a `wr` parameter, so the caller sees which calls allocate. The standard library does this: `os.read_file` reads a file into an arena. ```lane pub bool read_file([]u8 path, wr mem.Arena a, out []u8 data) { ``` From the standard library module `os`. It is written in Lane. `mem` also has `reset`, `copy` (which handles overlap), `eq` and `fill`. See [Modules and the standard library](https://lane.trisgram.com/docs/modules.md). --- # Data layout, SIMD and threads > soa and aos as part of the type, vector values against arrays in memory, vec loops that must vectorize, and par. This page is about the part of the language that the rest exists to carry: layout, vectors and threads. ## Layout is a property of the array type Layout is a qualifier on an array or slice type. `soa []Body` stores one array per field; `aos []Body` stores records back to back. The same `rec` works with either, and field access is written the same way, so changing the layout is changing a type, not rewriting the code. ```lane rec Body { f32 x; f32 vx; } nul step(wr soa []Body b, f32 dt) { par vec i in 0..b.len { b.x[i] += b.vx[i] * dt; } } ``` An `aos` slice is indexed as records: ```lane usz count_heavy(aos []Body b, f32 limit) { n := 0; for i in 0..b.len { if b[i].mass <= limit { nxt; } n += 1; if n == N { brk; } } ret n; } ``` A benchmark can build an `soa` array in place, which a test or `bench` block may use: ```lane bench "step 1M bodies" { soa [1_000_000]Body b; step(wr b, 1.0e-3); } ``` ## Vectors: a register value is not an array Vectors are written `x`. `f32x4` is one SIMD register holding four floats and is a value. `[4]f32` is four floats in memory. They are different types, and the language does not let one stand in for the other. `f32xw` has as many lanes as the target's widest vector: 16 with AVX-512, 8 with AVX2, 4 with NEON or SIMD128. ```lane f32xw splat_scale(f32xw v, f32 s) { ret v * f32xw(s); } ``` A kernel is written once against these width-generic types and lowered per target. Raw instructions are still available: functions in per-architecture modules (`x86.*`, `arm.*`), legal only in a branch that selects that architecture (see [Per-ISA code, hints and floats](https://lane.trisgram.com/docs/targets-hints.md)), and `asm { }` blocks. ## vec: vectorize or fail `vec i in a..b { }` must vectorize at the target's native width. If it cannot, that is a compile error, never a silent scalar loop. ```lane nul axpy(wr []f32 y, []f32 x, f32 a) { vec i in 0..y.len { y[i] += a * x[i]; } } ``` A `vec` loop that accumulates floats needs `reassoc` (see [floating point](https://lane.trisgram.com/docs/targets-hints.md#floating-point)); without it the loop is a compile error, never silently reordered. An indirect call inside a `vec` loop is a compile error. A vectorized kernel can name its scalar reference with `@ref`, and is then differential-tested against it on generated inputs: ```lane usz count_range_ref([]i32 col, i32 lo, i32 hi) { usz n = 0; for i in 0..col.len { if col[i] >= lo && col[i] < hi { n += 1; } } ret n; } ``` ```lane @ref(count_range_ref) usz count_range([]i32 col, i32 lo, i32 hi) { ``` ## par: threads as a keyword `par` runs a loop or block across cores and joins at the end. The `wr` sets of the pieces must not overlap. That condition is checkable because parameters carry access modes, and a call repeats the mode of each argument (see [Declarations and functions](https://lane.trisgram.com/docs/declarations.md)). How `par` schedules work, the job system and its C ABI, is still an open question in the specification. ## Shaders Lane is meant to compile a subset to SPIR-V later, so one language covers CPU kernels and GPU shaders, with shared records and math and with shader functions testable on the CPU. To keep that possible, the pure subset (no pointers, no function pointers, no `asm`, no `par`, no recursion) must stay a well-defined part of the language, record layout rules must be able to match GPU buffer layouts, and `vec` loops over `soa` data should be expressible as compute shaders. This is a design constraint, not a feature. --- # Per-ISA code, hints and floats > when selects declarations per target at compile time, optimizer hints are predeclared functions and attributes, and float code is strict unless a function relaxes it with @fp. This page is specified in section 8 of the language specification, marked provisional. ## Per-target code with when `when` tests the compile-time constants `isa`, `os`, `arch` and any constant set on the command line (`-D name=value`). It works around declarations and inside function bodies, and replaces a textual preprocessor: every branch is parsed on every target, and nothing is substituted as text. A `when` depends only on target constants, never on another declaration's body, which keeps compilation parallel and deterministic. ```lane u64 popcnt(u64 x) { when isa >= .bmi2 { ret x86.popcnt64(x); } else when arch == .aarch64 { ret arm.cnt64(x); } else { u64 n = 0; v := x; for v != 0 { v &= v - 1; n += 1; } ret n; } } ``` A `when` can also choose a constant: ```lane when isa == .avx512 { W :: 16; } else { W :: 8; } ``` Raw instructions are functions in per-architecture modules (`x86.*`, `arm.*`) and are legal only in a branch that selects that architecture. ## Hints Hints are predeclared functions and attributes, not keywords: | Form | Meaning | |---|---| | `likely(c)` `unlikely(c)` | Expected branch direction | | `assume(c)` | `c` holds here; the optimizer may rely on it. A function states what it requires of its callers with `assume` lines in its header (section 9.1) | | `unreachable()` | Control never gets here | | `prefetch(p)` | Bring the cache line at `p` in | | `is_const(x)` | True if `x` is known at compile time | | `@range(lo, hi)` on a parameter | The value lies in `lo..=hi` | | `@hot` `@cold` | Call frequency, for layout and inlining | | `@inline` `@noinline` | Force or forbid inlining | | `@opt(speed)` `@opt(size)` | What to optimize the function for | | `@align(n)` | Alignment of a record or a function | ```lane @hot @inline bool probe([]u64 keys, @range(0, 1023) u32 slot, u64 key) { prefetch(&keys[slot + 8]); if likely(keys[slot] == key) { ret true; } if unlikely(keys[slot] == 0) { ret false; } assume(slot < keys.len); ret probe_slow(keys, slot, key); } ``` ```lane @cold @noinline bool probe_slow([]u64 keys, u32 slot, u64 key) { ``` `assume(c)` inside a body is a hint. A function states what it requires of its callers with `assume` lines in its header; see [Contracts](https://lane.trisgram.com/docs/contracts.md). An attribute's `(` opens its arguments, unless the group starts with a type, has a comma directly inside it, and is followed by `fn` or by a name and `(`. So `@inline (f32, bool) find(u64 key)` is a function with a tuple return type, and `@align(64) rec A { }` has an argument. ## Floating point Float code is strict by default: operations happen in source order and nothing is fused, so results are bit-identical on every target. A function relaxes this with `@fp(...)`: | Flag | Allows | |---|---| | `strict` | Nothing (the default) | | `fma` | Fusing `a * b + c` into one multiply-add | | `reassoc` | Reordering sums and products | | `recip` | `x / y` as `x * (1 / y)`, approximate reciprocal and rsqrt | | `nonan` | Assuming no NaN or infinity | | `fast` | All of the above | The function below allows fusing and reordering, which a vectorized float sum needs. ```lane @fp(fma, reassoc) f32 dot([]f32 a, []f32 b) { f32 s = 0; vec i in 0..a.len { s += a[i] * b[i]; } ret s; } ``` A `vec` loop that accumulates floats needs `reassoc`; without it the loop is a compile error. `fma(a, b, c)` is always one fused multiply-add, whatever the flags. ```lane f32 lerp(f32 a, f32 b, f32 t) { ret fma(t, b - a, a); } ``` Float literals are `3.14`, `1e9` and `1.5e-3`; a fraction needs a digit after the dot, so `0..n` is an integer followed by `..`. There are no literal suffixes: convert with `f32(1)`. ## Raw assembly `asm { }` holds raw instructions up to the matching `}`. For now its content must consist of valid Lane tokens, and its syntax is still an open question. ```lane nul pause() { asm { pause } } ``` --- # Contracts and tests > Functions that state what they require with assume and what they return with examples, test and bench blocks, and the report format. This is the contract design from section 9.1 of the language specification: what a function requires with `assume`, what it returns with examples, and how `test` and `bench` blocks and the report file fit in. ## The design Between its parameter list and its body a function may state what it requires and what it returns. Each line is optional, there may be any number, each ends with `;`, and each may end with a message, a string literal after a comma, which is shown on failure and stored in the report. ```lane i32 clamp(i32 v, i32 lo, i32 hi) assume lo <= hi, "lo must not exceed hi"; test (5, 0, 3) == 3, "expected 3 when given 5 for range 0 to 3"; test (-1, 0, 3) == 0; test (7, 3, 3) == 3; test (5, 3, 0) fails; { if v < lo { ret lo; } if v > hi { ret hi; } ret v; } ``` - **`assume condition;`** is a promise every caller must keep. The condition is a `bool` expression over the parameters and constants, with no effects. In test and debug builds it is checked at every call, and a broken promise stops the program with the place, the condition and the message. In release builds the optimizer may rely on it: value ranges, removed checks, arithmetic that cannot overflow. `--checked` keeps the checks in a release build. This is the only way a function gives the optimizer facts about its inputs. - **`test (arguments) == value;`** is an example: called with these arguments the function returns exactly this value. Equality is exact; there are no tolerances. The arguments must satisfy every `assume`, or the example is a compile error. - **`test (arguments) fails;`** is an example of wrong input: these arguments break an `assume`. The compiler checks that they do. `fails` is not a keyword; it is only read in this position. **Every promise must be tested on both sides.** For each `assume` there must be at least one example that satisfies it and at least one `fails` example that breaks it; otherwise the function is refused when tests are on. When the condition is a simple comparison between integers, the report also says whether the examples sit exactly on the boundary: the last allowed value and the first refused one. Examples also serve as speed hints: they show typical arguments, so the optimizer may use them to guess which branches are likely and what is worth inlining. A wrong guess costs speed, never correctness. ## Running and reporting - `--tests=all`, `changed` or `off` selects what runs. `changed`, the default for a build, re-runs an example only when its function, anything that function calls, its `assume` lines, the example itself or the target has changed since it last passed. - At the end of compilation a summary line is printed (examples run, skipped as unchanged, failed) and each failure is printed with its place, its message and the expected and actual values. A failed example fails the build. - The first version covers functions that compute a result from their arguments. Functions with `wr` or `out` parameters or other effects are tested with `test "name" { }` blocks; `assume` applies to any function. ## test and bench blocks `test "name" { }` and `bench "name" { }` are compiled only in their modes. ```lane test "clamp keeps a value inside its range" { io.expect(clamp(5, 0, 3), 3); io.expect(clamp('a', 'b', 'z'), 'b'); } ``` A kernel marked `@ref(f)` is differential-tested against `f`, its scalar reference, on generated inputs. Coverage is produced by the compiler at basic-block granularity. ## Reports are not JSON Test, benchmark and coverage results are written to a binary report file in struct-of-arrays form: a header with the record count and the offset of each column, then one array per field (outcome, file, line, function, expected, actual, time and so on) and one string table. Columns are fixed-width, aligned and in the machine's native layout, so a reader maps the file and uses the arrays in place with no parsing step, and a filter or a count is a scan over one column. `lane report ` is its viewer: it prints the records as plain lines, one per record, and filters them by file, function or outcome. Diagnostics stay plain lines on standard error (`path:line:col: error: message`), and no report or diagnostic uses JSON. ## How the examples on this site are checked Lane has a test runner written in Lane, which builds each test program, runs it, and compares its standard output and exit code with the expected bytes. It is not the contract system above: it is how the 1668 programs behind this site are checked. See [The lane command and its tests](https://lane.trisgram.com/docs/tooling.md). --- # Modules and the standard library > One file is one module. use, pub, ext and @lib, and what io, fmt, mem, os and bufio contain. ## Modules One file is one module. `use name;` imports the module in `name.ln` next to the importing file, or else the standard module of that name; its `pub` functions are called as `name.function(...)`. `pub` exports a declaration: a function, a constant, a record or an enum, reached from another module as `module.NAME` or `module.Type`, also in the type of a field or a parameter. A name that is not `pub` is refused, and a module's own errors are reported in that module. A module with some public and some private declarations: ```lane pub CAP :: 8; HIDDEN :: 3; pub enum Open { a } enum Closed { a } pub rec Pub { u8 a; } rec Priv { u8 a; } ``` Verified: one module of a multi-module program. Using a private name from another module is an error: ```lane use limits; nul main() { limits.Priv p; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:14: error: `limits.Priv` is not `pub` ``` The module path and package layout are not decided yet. ## C imports and exports `ext` with `;` imports a C-ABI symbol and `ext` with a body exports one. `@lib` names the library. A slice cannot cross the C ABI (pass a pointer and a length), neither can an array (pass a pointer), nor a record. An `ext` function takes no access modes; it takes pointers. ```lane @lib("kernel32") ext *nul VirtualAlloc(*nul address, usz size, u32 kind, u32 protect); @lib("kernel32") ext i32 VirtualFree(*nul address, usz size, u32 kind); ``` From the standard library module `mem`. It is written in Lane. ```lane rec A { u32 x; } @lib("x") ext nul f(A a); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:11: error: a record cannot cross the C ABI; pass a pointer ``` ## The standard library The standard library is embedded in the compiler and written in Lane on `ext` imports of the host operating system's API (`kernel32` on Windows). A std module may `use` another. Only these functions are `pub`; paths and text are `[]u8` without a terminator. | Module | Contents | |---|---| | `io` | `print`, `eprint` (standard error), `println`, `print_u64` | | `fmt` | `dec(u64, wr [20]u8)`, `dec_signed(i64, wr [20]u8)`, `hex(u64, wr [16]u8)`: the digits as the tail of the buffer; `hex` is lowercase without leading zeros | | `mem` | `rec Arena`, `arena_init`, `alloc`, `reset`, `release`, `copy`, `eq`, `fill` | | `os` | `exit`, `arg_count`, `arg`, `read_file`, `write_file`, `file_size`, `ticks`, `ticks_per_second` | | `bufio` | `rec Writer`, `stdout_writer`, `stderr_writer`, `flush`, `write` | ### io ```lane pub nul print([]u8 s) { ``` From the standard library module `io`. It is written in Lane. ```lane pub nul println([]u8 s) { ``` From the standard library module `io`. It is written in Lane. ### fmt `fmt` formats into a buffer the caller owns and returns the digits as the tail of it. ```lane pub []u8 dec(u64 v, wr [DEC_DIGITS]u8 buf) { ``` From the standard library module `fmt`. It is written in Lane. ```lane pub []u8 hex(u64 v, wr [HEX_DIGITS]u8 buf) { ``` From the standard library module `fmt`. It is written in Lane. ### mem An `Arena` is a block from `VirtualAlloc` handed out in order. `alloc` returns zeroed memory aligned as asked (a power of two) or an empty slice when it does not fit, and `reset` zeroes what was used. `copy` takes `min(dst.len, src.len)` bytes and handles overlap. See [Memory](https://lane.trisgram.com/docs/memory.md). ```lane pub bool arena_init(out Arena a, usz cap) { ``` From the standard library module `mem`. It is written in Lane. ```lane pub nul copy(wr []u8 dst, []u8 src) { ``` From the standard library module `mem`. It is written in Lane. ```lane pub bool eq([]u8 a, []u8 b) { ``` From the standard library module `mem`. It is written in Lane. ```lane pub nul fill(wr []u8 dst, u8 v) { ``` From the standard library module `mem`. It is written in Lane. ### os `arg(0)` is the program name and `arg_count` counts it. Command-line arguments are ASCII: a character outside ASCII becomes the byte 0xff. Paths are ASCII, and a path with a byte above 0x7f or a zero byte is not usable. `read_file` stores the file in arena memory and sets its `out []u8` parameter; on any failure it returns false, sets the slice to empty and leaves the arena as it was. Only disk files are read. ```lane pub nul exit(i32 code) { ``` From the standard library module `os`. It is written in Lane. ```lane pub bool read_file([]u8 path, wr mem.Arena a, out []u8 data) { ``` From the standard library module `os`. It is written in Lane. ```lane pub bool write_file([]u8 path, []u8 data) { ``` From the standard library module `os`. It is written in Lane. ```lane pub u64 ticks() { ``` From the standard library module `os`. It is written in Lane. ### bufio A `bufio.Writer` collects output in a buffer the caller owns, so that many small writes become few system calls. Nothing is written by itself at the end of the program: call `flush`. ```lane pub rec Writer { bool to_error; *u8 buf; usz len; usz cap; } ``` From the standard library module `bufio`. It is written in Lane. ```lane pub nul write(wr Writer w, []u8 s) { ``` From the standard library module `bufio`. It is written in Lane. ```lane pub nul flush(wr Writer w) { ``` From the standard library module `bufio`. It is written in Lane. --- # The lane command and its tests > lane lex, parse and build; exit codes and diagnostics; and how the examples on this site are verified. ## The lane command The compiler is called `lane`. The compiler is written in Lane and builds itself to a byte-identical result (the fixpoint), on Windows, Linux and macOS (arm64); a bootstrap compiler only starts the chain. See the [roadmap](https://lane.trisgram.com/roadmap.md) for where it is going. Three commands exist, and all three exit 1 if a file has an error and 2 on a usage or I/O error. ```sh lane lex lane parse [-j ] ... lane build [-j ] [-o ] ``` - `lane lex` prints one line per token: ` `, with byte offsets, ending with the `Eof` token. Any other implementation of the lexer must print these bytes exactly. - `lane parse` prints each file's syntax tree, one declaration per line, and diagnostics as `path:line:col: error: message` on standard error. Files are parsed in parallel and the output does not depend on the thread count. - `lane build` compiles a program to an executable. Functions are compiled in parallel and the executable's bytes do not depend on the thread count. Diagnostics are plain lines on standard error: `path:line:col: error: message`. The parser reports the first error in each top-level declaration and resumes after the `}` or `;` that ends it, so one run reports an error in every broken declaration. A construct that the parser accepts but the compiler cannot build yet is refused with a "not supported ... yet" error, never compiled into something else. The dated Status section of the [agent docs](https://lane.trisgram.com/docs/agents.md) lists what the current compiler builds. The generated code is deliberately unoptimized: every value is computed into a register and every variable and temporary lives in a stack slot. ## How the examples here are verified Every program on this site comes from the compiler's own test suite, which has 1668 programs: 556 that must build and run, and 1112 that the compiler must refuse. A test names the exact bytes the program must write to standard output, its exit code, and for a refusal the compiler's exit code and message. A test passes only when all of them match byte for byte. The test runner is itself written in Lane. It builds each program, runs it with a time limit of 10 seconds in a clean environment, and reports the first differing byte with a window of what was expected and what was got. The same programs are meant to be built for every target and checked against the same expected bytes; that is how parity between instruction sets is intended to be tested (see [Targets](https://lane.trisgram.com/targets.md)). Where a page shows "Verified", the standard output, exit code or compiler message next to it was read from those expectations when this site was built, so the claim is checked at every build. --- # Lane for agents > How to read and write Lane from a program: the index files, the one-page cheat sheet, verified examples and the error reference. These pages are plain Markdown with no JavaScript needed. Every docs page has a Markdown twin at the same path with `.md` added, and the whole reference is one file. ## Start here - [Lane in one page](https://lane.trisgram.com/docs/agents/lane-in-one-page.md): every construct with one minimal example, and the exact rules that are easy to get wrong. - [Verified examples](https://lane.trisgram.com/docs/agents/examples.md): programs from the test suite with their expected standard output and exit codes, grouped by feature. - [Error reference](https://lane.trisgram.com/docs/agents/errors.md): every distinct compiler message with a program that triggers it. ## Index files - `/llms.txt`: the title, a summary, and a link to every page in Markdown. - `/llms-full.txt`: the whole language reference in one plain-text file. - `/docs/.md`: the Markdown twin of each docs page. ## Status (as of 2026-10-22) Which constructs the current compiler accepts. The language is larger than this list; see the roadmap for what comes next. - **Builds:** integers and bool, f32 and f64 (strict IEEE, with a native square root), pointers, slices, arrays, records, enums, match, constants, functions, access modes (wr, out) and their aliasing check, if, for (all three forms), brk, nxt, ret, defer, use, pub, ext with @lib, embed, size_of, align_of, cast, slice, implicit conversions between number types when nothing can be lost, fixed-width vector types and their operations, contracts (assume lines and test examples, run during builds for every target, with exact float results and examples on exported library functions), and the standard library modules io, fmt, mem, os, bufio and float, plus files and processes on Windows. Constants that divide an integer by zero, or that are infinity or NaN, are compile-time errors. - **Parsed only:** vec and par, soa and aos, when, union, generics ($T), functions as values, variadic parameters, several results, attributes other than @lib, and test and bench blocks. The compiler refuses them with a "not supported ... yet" error. - **Not accepted:** record and array literals, returning a record or an array, and the number types f16, un8, un16, sn8, sn16, bf16, f8e4m3 and f8e5m2. - **Targets:** x86-64 Windows executables, x86-64 Linux executables (--target linux, static, no C library), wasm32 and wasm64 modules, AArch64 Linux and macOS (arm64) executables, and RISC-V 64 Linux executables. These describe the development compiler on 2026-10-22; the latest published release may predate some of them, and the Downloads page offers the latest published release. Optimization at -O1 is available on x86-64, AArch64 and RISC-V 64, and floats are optimized on x86-64. - **Compiler:** The compiler is written in Lane and builds itself to a byte-identical result (the fixpoint), on Windows, Linux and macOS (arm64); a bootstrap compiler only starts the chain. ## What an agent can rely on - Every Lane example on this site comes from a program that the compiler's test suite builds or parses, and is checked against it when the site is built. An example is never retyped. - The test suite is the ground truth: a "Verified" label means the suite builds and runs the program and compares its standard output and exit code, or compares the compiler's message when the program must be refused. - A construct the parser accepts but the compiler cannot build yet is refused with a "not supported ... yet" message. The Status section below lists them. - Compiler messages are plain lines, `path:line:col: error: message`, on standard error, with exit code 1. No tool output is JSON. - The language specification is the source of truth; this site is regenerated from it, and the footer says when the docs were last updated. --- # Error reference > Every distinct compiler message that the test suite checks, with a program that triggers it. 196 distinct compiler messages, each with one program from the test suite that triggers it. Messages are written `path:line:col: error: message` on standard error and the compiler exits with 1. In a heading, `` stands for a name or type that varies and `` for a number; the listing under it is a real program and its real output. This covers the checker and the backend (types, access modes, constants, records, enums, `match`, control flow, modules). Messages for malformed tokens and syntax are tested separately. Every program here is refused whole: nothing is run. A message that says "stage-0 backend" is a limit of the current compiler, not a rule of the language. ### a bound must be a ``, found `` Seen in 2 test programs. ```lane nul main() { [4]u8 a; u32 i = 0; []u8 s = a[i..2]; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:45: error: a bound must be a `usz`, found `u32` ``` ### a character literal is one byte, found Seen in 1 test program. ```lane nul main() { u8 c = 'ab'; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:21: error: a character literal is one byte, found 2 ``` ### a conversion takes no access modes Seen in 1 test program. ```lane N :: u8(wr 1); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:12: error: a conversion takes no access modes ``` ### a conversion to `` takes one value Seen in 7 test programs. ```lane N :: u8(); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:8: error: a conversion to `u8` takes one value ``` ### a length must be a ``, found `` Seen in 1 test program. ```lane nul main() { *u8 p = nil; u32 n = 1; []u8 s = slice(p, n); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:56: error: a length must be a `usz`, found `u32` ``` ### a `match` on an integer needs an `else` arm Seen in 2 test programs. ```lane nul main() { u8 x = 1; match x { } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:24: error: a `match` on an integer needs an `else` arm ``` ### a pointer cannot be indexed; make a slice of it with `` Seen in 3 test programs. ```lane nul main() { *u8 p = nil; p[0] = 1; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:28: error: a pointer cannot be indexed; make a slice of it with `slice(p, n)` ``` ### a pointer cannot be sliced; make a slice of it with `` Seen in 1 test program. ```lane nul main() { *u8 p = nil; []u8 s = p[0..1]; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:37: error: a pointer cannot be sliced; make a slice of it with `slice(p, n)` ``` ### a pointer cannot be the right operand of ``; write `` Seen in 3 test programs. ```lane nul f(*u8 p) { *u8 q = 1 + p; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:26: error: a pointer cannot be the right operand of `+`; write `p + n` ``` ### a range cannot be a pattern for an enum; name the variants Seen in 1 test program. ```lane enum C { red, green } enum D { x } nul main() { C c; match c { .red..=.green { } else { } } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:3:29: error: a range cannot be a pattern for an enum; name the variants ``` ### a range of elements is not a place; it cannot be assigned or have its address taken Seen in 2 test programs. ```lane nul main() { [4]u8 a; a[1..3] = 1; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:24: error: a range of elements is not a place; it cannot be assigned or have its address taken ``` ### a record cannot cross the C ABI; pass a pointer Seen in 1 test program. ```lane rec A { u32 x; } @lib("x") ext nul f(A a); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:11: error: a record cannot cross the C ABI; pass a pointer ``` ### a slice cannot cross the C ABI; pass a pointer and a length Seen in 1 test program. ```lane @lib("k") ext nul f([]u8 s); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:11: error: a slice cannot cross the C ABI; pass a pointer and a length ``` ### a slice of `` has no elements; use `` for an untyped pointer Seen in 1 test program. ```lane rec A { []nul x; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:15: error: a slice of `nul` has no elements; use `*nul` for an untyped pointer ``` ### a variable cannot have type `` Seen in 1 test program. ```lane nul main() { nul a; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: a variable cannot have type `nul` ``` ### a `` cannot be dereferenced; `` it to a typed pointer first Seen in 3 test programs. ```lane nul main() { *nul p = nil; *p = 1; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:28: error: a `*nul` cannot be dereferenced; `cast` it to a typed pointer first ``` ### an argument passed as `out` must be a variable, an element, a field or a dereference that can be written Seen in 4 test programs. ```lane nul f(out u32 x) { x = 1; } nul main() { f(out 1); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:20: error: an argument passed as `out` must be a variable, an element, a field or a dereference that can be written ``` ### an argument passed as `wr` must be a variable, an element, a field or a dereference that can be written Seen in 16 test programs. ```lane nul f(wr u32 x) { } nul main() { f(wr 1); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:19: error: an argument passed as `wr` must be a variable, an element, a field or a dereference that can be written ``` ### an array cannot cross the C ABI; pass a pointer Seen in 1 test program. ```lane @lib("k") ext nul f([4]u8 x); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:11: error: an array cannot cross the C ABI; pass a pointer ``` ### an array length must be an integer Seen in 1 test program. ```lane N :: true; nul main() { [N]u8 a; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:15: error: an array length must be an integer ``` ### an array needs at least one element Seen in 3 test programs. ```lane nul main() { [0]u8 a; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: an array needs at least one element ``` ### an array of `` has no elements Seen in 1 test program. ```lane nul main() { [4]nul a; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: an array of `nul` has no elements ``` ### an `ext` function takes no access modes; pass a pointer Seen in 3 test programs. ```lane @lib("k") ext nul f(wr u32 x); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:11: error: an `ext` function takes no access modes; pass a pointer ``` ### an index must be a ``, found `` Seen in 3 test programs. ```lane nul main() { [4]u8 a; a[true] = 1; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:25: error: an index must be a `usz`, found `bool` ``` ### `brk` outside a loop Seen in 2 test programs. ```lane nul main() { brk; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: `brk` outside a loop ``` ### cannot convert `` to `` Seen in 3 test programs. ```lane i32 main() { ret i32("x"); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:22: error: cannot convert `[]u8` to `i32` ``` ### cannot embed ``: not a regular file Seen in 1 test program. This program has several modules; all are shown, root module last. Module `main.ln`: ```lane nul main() { []u8 s = embed(".."); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:29: error: cannot embed `..`: not a regular file ``` ### cannot embed ``: only ASCII paths are supported Seen in 1 test program. This program has several modules; all are shown, root module last. Module `main.ln`: ```lane nul main() { []u8 s = embed("\xff.txt"); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:29: error: cannot embed `\xff.txt`: only ASCII paths are supported ``` ### cannot embed ``: the file cannot be read Seen in 2 test programs. This program has several modules; all are shown, root module last. Module `main.ln`: ```lane nul main() { []u8 s = embed("nope.txt"); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:29: error: cannot embed `nope.txt`: the file cannot be read ``` ### constant `` = - does not fit in `` Seen in 3 test programs. ```lane N :: -1; nul main() { u32 x = N; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:22: error: constant `N` = -1 does not fit in `u32` ``` ### constant `` = does not fit in `` Seen in 5 test programs. ```lane N :: 300; nul main() { u8 x = N; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:21: error: constant `N` = 300 does not fit in `u8` ``` ### constant `` cannot be assigned Seen in 2 test programs. ```lane N :: 3; nul main() { N = 4; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:14: error: constant `N` cannot be assigned ``` ### constant `` is defined in terms of itself Seen in 4 test programs. ```lane A :: A; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: constant `A` is defined in terms of itself ``` ### constant `` is defined in terms of itself through `` Seen in 12 test programs. ```lane A :: B; B :: A; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: constant `A` is defined in terms of itself through `B` ``` ### constant `` is defined in terms of itself through ``, `` Seen in 2 test programs. ```lane A :: B; B :: C; C :: A; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: constant `A` is defined in terms of itself through `B`, `C` ``` ### constant `` is defined in terms of itself through ``, ``, ``, ``, `` Seen in 1 test program. ```lane C0 :: C1 + 1; C1 :: C2 + 1; C2 :: C3 + 1; C3 :: C4 + 1; C4 :: C5 + 1; C5 :: C0 + 1; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: constant `C0` is defined in terms of itself through `C1`, `C2`, `C3`, `C4`, `C5` ``` ### constant `` is defined in terms of itself through ``, ``, ``, ``, `` and more Seen in 5 test programs. ```lane C0 :: C1 + 1; C1 :: C2 + 1; C2 :: C3 + 1; C3 :: C4 + 1; C4 :: C5 + 1; C5 :: C6 + 1; C6 :: C0 + 1; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: constant `C0` is defined in terms of itself through `C1`, `C2`, `C3`, `C4`, `C5` and 1 more ``` ### division by zero in a constant expression Seen in 5 test programs. ```lane N :: 10 / 0; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:9: error: division by zero in a constant expression ``` ### enum `` has no variants Seen in 1 test program. ```lane enum E { } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: enum `E` has no variants ``` ### expected ``, found a character Seen in 2 test programs. ```lane nul main() { bool b = 'a'; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:23: error: expected `bool`, found a character ``` ### expected ``, found an enum value Seen in 5 test programs. ```lane enum E { a } nul main() { u32 x = .a; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:22: error: expected `u32`, found an enum value ``` ### expected ``, found an integer Seen in 16 test programs. ```lane nul main() { if 1 { } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:17: error: expected `bool`, found an integer ``` ### expected ``, found `` Seen in 65 test programs. ```lane nul main() { a := 1 } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:21: error: expected `;`, found `}` ``` ### field `` cannot have type `` Seen in 1 test program. ```lane rec A { nul x; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:13: error: field `x` cannot have type `nul` ``` ### field `` is declared twice in `` Seen in 1 test program. ```lane rec A { u32 x; u8 x; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:19: error: field `x` is declared twice in `A` ``` ### imported function `` needs `` naming its library Seen in 1 test program. ```lane ext nul f(); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: imported function `f` needs `@lib("name")` naming its library ``` ### loop variable `` is read-only Seen in 3 test programs. ```lane nul main() { for i in u32(0)..3 { i = 1; } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:35: error: loop variable `i` is read-only ``` ### loop variable `` is read-only; it cannot be passed as `wr` Seen in 1 test program. ```lane nul g(wr u32 y) { } nul main() { for i in u32(0)..3 { g(wr i); } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:40: error: loop variable `i` is read-only; it cannot be passed as `wr` ``` ### loop variable `` is read-only; its address cannot be taken Seen in 1 test program. ```lane nul main() { for i in u32(0)..3 { p := &i; } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:41: error: loop variable `i` is read-only; its address cannot be taken ``` ### `match` needs an integer or an enum, found `` Seen in 4 test programs. ```lane nul main() { match true { else { } } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:20: error: `match` needs an integer or an enum, found `bool` ``` ### module `` has no function `` Seen in 1 test program. This program has several modules; all are shown, root module last. Module `greet.ln`: ```lane use io; pub nul hi() { io.print("hi\n"); } nul hidden() { } ``` Verified: one module of a multi-module program. Module `main.ln`: ```lane use greet; nul main() { greet.nope(); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:19: error: module `greet` has no function `nope` ``` ### module `` has no type `` Seen in 2 test programs. ```lane use io; nul main() { io.Missing m; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:14: error: module `io` has no type `Missing` ``` ### module `` has no `` Seen in 1 test program. This program has several modules; all are shown, root module last. Module `m1.ln`: ```lane pub rec S { u8 a; } pub enum E { a } ``` Verified: one module of a multi-module program. Module `m2.ln`: ```lane pub rec S { u8 a; } pub enum E { a } ``` Verified: one module of a multi-module program. Module `main.ln`: ```lane use m1; nul main() { x := m1.ZZ; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:21: error: module `m1` has no `ZZ` ``` ### module `` is imported twice Seen in 1 test program. ```lane use io; use io; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:1: error: module `io` is imported twice ``` ### module `` not found Seen in 1 test program. ```lane use nope; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: module `nope` not found ``` ### is not a variant of `` Seen in 2 test programs. ```lane enum C { red, green } enum D { x } nul main() { C c; match c { C(7) { } else { } } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:3:29: error: 7 is not a variant of `C` ``` ### nested too deeply: stage 0 allows levels Seen in 14 test programs. ```lane i32 main() { i32 a = 5; ret ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~a; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:284: error: nested too deeply: stage 0 allows 256 levels ``` ### `nil` needs a pointer type here Seen in 4 test programs. ```lane nul main() { a := nil; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:19: error: `nil` needs a pointer type here ``` ### not supported by the stage-0 backend yet: a range outside ``, an index and a `match` pattern Seen in 2 test programs. ```lane N :: 1 .. 2; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:8: error: not supported by the stage-0 backend yet: a range outside `for ... in`, an index and a `match` pattern ``` ### not supported by the stage-0 backend yet: `asm` Seen in 1 test program. ```lane nul main() { asm { nop } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: not supported by the stage-0 backend yet: `asm` ``` ### not supported by the stage-0 backend yet: assigning a whole array Seen in 3 test programs. ```lane nul main() { [4]u8 a; [4]u8 b; a = b; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:32: error: not supported by the stage-0 backend yet: assigning a whole array ``` ### not supported by the stage-0 backend yet: `defer` Seen in 1 test program. ```lane nul main() { defer f(); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: not supported by the stage-0 backend yet: `defer` ``` ### not supported by the stage-0 backend yet: exported `ext` functions Seen in 1 test program. ```lane ext nul f() { } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: not supported by the stage-0 backend yet: exported `ext` functions ``` ### not supported by the stage-0 backend yet: floating point Seen in 2 test programs. ```lane N :: 1 + 2.5; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:10: error: not supported by the stage-0 backend yet: floating point ``` ### not supported by the stage-0 backend yet: generic parameters Seen in 1 test program. ```lane T id($T v) { ret v; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: not supported by the stage-0 backend yet: generic parameters ``` ### not supported by the stage-0 backend yet: initializing an array from another array Seen in 2 test programs. ```lane nul main() { [4]u8 a; b := a; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:28: error: not supported by the stage-0 backend yet: initializing an array from another array ``` ### not supported by the stage-0 backend yet: multiple return values Seen in 3 test programs. ```lane nul main() { ret 1, 2; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:18: error: not supported by the stage-0 backend yet: multiple return values ``` ### not supported by the stage-0 backend yet: nested module paths Seen in 1 test program. ```lane use a.b; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: not supported by the stage-0 backend yet: nested module paths ``` ### not supported by the stage-0 backend yet: `par` Seen in 1 test program. ```lane nul main() { par { } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: not supported by the stage-0 backend yet: `par` ``` ### not supported by the stage-0 backend yet: record literals Seen in 2 test programs. ```lane rec A { u8 a; } nul main() { A a = A(); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:20: error: not supported by the stage-0 backend yet: record literals ``` ### not supported by the stage-0 backend yet: returning a record; use an `out` parameter instead Seen in 3 test programs. ```lane rec A { u32 x; } pub A f() { } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:5: error: not supported by the stage-0 backend yet: returning a record; use an `out` parameter instead ``` ### not supported by the stage-0 backend yet: returning an array Seen in 1 test program. ```lane [4]u8 f() { } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: not supported by the stage-0 backend yet: returning an array ``` ### not supported by the stage-0 backend yet: several targets in one statement Seen in 3 test programs. ```lane nul f() { } nul main() { a, b = f(); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:14: error: not supported by the stage-0 backend yet: several targets in one statement ``` ### not supported by the stage-0 backend yet: spread arguments Seen in 1 test program. ```lane nul f([]u8 a) { } nul main() { []u8 s = "ab"; f(..s); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:33: error: not supported by the stage-0 backend yet: spread arguments ``` ### not supported by the stage-0 backend yet: the type `` Seen in 4 test programs. ```lane nul main() { a.b.c x; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: not supported by the stage-0 backend yet: the type `a.b.c` ``` ### not supported by the stage-0 backend yet: the `` attribute here Seen in 1 test program. ```lane @inline nul f() { } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:9: error: not supported by the stage-0 backend yet: the `@inline` attribute here ``` ### not supported by the stage-0 backend yet: using `` as a value; call it instead Seen in 1 test program. ```lane use io; nul main() { p := io.print; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:21: error: not supported by the stage-0 backend yet: using `io.print` as a value; call it instead ``` ### not supported by the stage-0 backend yet: variadic parameters Seen in 1 test program. ```lane nul f(..[]u32 a) { } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: not supported by the stage-0 backend yet: variadic parameters ``` ### not supported by the stage-0 backend yet: `vec` loops Seen in 1 test program. ```lane nul main() { vec i in 0..4 { } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: not supported by the stage-0 backend yet: `vec` loops ``` ### not supported by the stage-0 backend yet: `when` Seen in 1 test program. ```lane nul main() { when true { } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: not supported by the stage-0 backend yet: `when` ``` ### not supported by the stage-0 backend yet: `when` declarations Seen in 1 test program. ```lane when isa == .avx2 { } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: not supported by the stage-0 backend yet: `when` declarations ``` ### not supported by the stage-0 backend yet: `` over anything but a range Seen in 1 test program. ```lane nul main() { []u8 s = "ab"; for c in s { } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:38: error: not supported by the stage-0 backend yet: `for ... in` over anything but a range ``` ### `nxt` outside a loop Seen in 2 test programs. ```lane nul main() { nxt; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: `nxt` outside a loop ``` ### `out` parameter `` is not assigned on every path to the end of `` Seen in 24 test programs. ```lane nul f(out u32 x) { } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: `out` parameter `x` is not assigned on every path to the end of `f` ``` ### `out` parameter `` is not assigned on every path to this `ret` Seen in 6 test programs. ```lane u32 f(out u32 x) { ret 1; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:20: error: `out` parameter `x` is not assigned on every path to this `ret` ``` ### `out` parameter `` is read before it is assigned Seen in 37 test programs. ```lane nul f(out u32 x) { x = x; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:24: error: `out` parameter `x` is read before it is assigned ``` ### parameter `` is declared twice Seen in 1 test program. ```lane nul f(u32 a, u64 a) { } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: parameter `a` is declared twice ``` ### parameter `` is read-only Seen in 10 test programs. ```lane nul f(u32 a) { a = 1; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:16: error: parameter `a` is read-only ``` ### parameter `` is read-only; it cannot be passed as `out` Seen in 3 test programs. ```lane nul g(out u32 y) { y = 1; } nul f(u32 x) { g(out x); } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:22: error: parameter `x` is read-only; it cannot be passed as `out` ``` ### parameter `` is read-only; it cannot be passed as `wr` Seen in 4 test programs. ```lane nul g(wr u32 y) { } nul f(u32 x) { g(wr x); } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:21: error: parameter `x` is read-only; it cannot be passed as `wr` ``` ### parameter `` is read-only; its address cannot be taken Seen in 4 test programs. ```lane nul f(u32 a) { p := &a; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:22: error: parameter `a` is read-only; its address cannot be taken ``` ### parameter `` is read-only; its elements cannot be assigned Seen in 9 test programs. ```lane nul f([]u8 s) { s[0] = 1; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:18: error: parameter `s` is read-only; its elements cannot be assigned ``` ### parameter `` is read-only; its elements cannot be passed as `out` Seen in 1 test program. ```lane nul g(out []u8 d) { d = "x"; } nul f([2][]u8 a) { g(out a[0]); } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:27: error: parameter `a` is read-only; its elements cannot be passed as `out` ``` ### parameter `` is read-only; its elements cannot be passed as `wr` Seen in 3 test programs. ```lane nul g(wr u32 y) { } nul f([4]u32 a) { g(wr a[1]); } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:25: error: parameter `a` is read-only; its elements cannot be passed as `wr` ``` ### parameter `` is read-only; its fields cannot be assigned Seen in 3 test programs. ```lane rec A { u32 x; [2]u32 arr; } nul f(A r) { r.x = 1; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:15: error: parameter `r` is read-only; its fields cannot be assigned ``` ### parameter `` is read-only; its fields cannot be passed as `out` Seen in 2 test programs. ```lane nul g(out []u8 d) { d = "x"; } rec H { []u8 s; } nul f(H h) { g(out h.s); } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:3:21: error: parameter `h` is read-only; its fields cannot be passed as `out` ``` ### parameter `` is read-only; its fields cannot be passed as `wr` Seen in 2 test programs. ```lane rec A { u32 x; [2]u32 arr; } nul g(wr u32 y) { } nul f(A r) { g(wr r.x); } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:3:20: error: parameter `r` is read-only; its fields cannot be passed as `wr` ``` ### parameter `` is read-only; the address of its elements cannot be taken Seen in 3 test programs. ```lane nul f([]u8 s) { p := &s[0]; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:24: error: parameter `s` is read-only; the address of its elements cannot be taken ``` ### parameter `` is read-only; the address of its fields cannot be taken Seen in 1 test program. ```lane rec A { u32 x; [2]u32 arr; } nul f(A r) { p := &r.x; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:21: error: parameter `r` is read-only; the address of its fields cannot be taken ``` ### parameter `` of `` takes no access mode, but the argument has `wr` Seen in 3 test programs. ```lane nul f(u32 x) { } nul main() { u32 a = 1; f(wr a); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:30: error: parameter `x` of `f` takes no access mode, but the argument has `wr` ``` ### parameter `` of `` takes `out`, but the argument has no access mode Seen in 1 test program. ```lane nul g(out []u8 d) { d = "x"; } nul main() { []u8 t; g(t); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:24: error: parameter `d` of `g` takes `out`, but the argument has no access mode ``` ### parameter `` of `` takes `out`, but the argument has `wr` Seen in 2 test programs. ```lane nul f(out u32 x) { x = 1; } nul main() { u32 a = 1; f(wr a); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:30: error: parameter `x` of `f` takes `out`, but the argument has `wr` ``` ### parameter `` of `` takes `wr`, but the argument has no access mode Seen in 5 test programs. ```lane nul f(wr []u8 a) { } nul main() { [4]u8 b; f(b); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:25: error: parameter `a` of `f` takes `wr`, but the argument has no access mode ``` ### parameter `` of `` takes `wr`, but the argument has `out` Seen in 1 test program. ```lane nul f(wr u32 x) { } nul main() { u32 a = 1; f(out a); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:31: error: parameter `x` of `f` takes `wr`, but the argument has `out` ``` ### record `` contains itself through ``, ``; a field on the way must be a pointer or a slice Seen in 1 test program. ```lane rec A { [3][2]B b; } rec B { C c; } rec C { A a; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:3:11: error: record `A` contains itself through `B`, `C`; a field on the way must be a pointer or a slice ``` ### record `` contains itself through ``; a field on the way must be a pointer or a slice Seen in 5 test programs. ```lane rec A { B b; } rec B { A a; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:11: error: record `A` contains itself through `B`; a field on the way must be a pointer or a slice ``` ### record `` contains itself; a field of its own type must be a pointer or a slice Seen in 8 test programs. ```lane rec A { A a; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:11: error: record `A` contains itself; a field of its own type must be a pointer or a slice ``` ### record `` has no fields Seen in 1 test program. ```lane rec A { } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: record `A` has no fields ``` ### record `` is larger than the stage-0 limit of GiB Seen in 1 test program. ```lane rec A { [1073741824]u8 a; u8 b; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:30: error: record `A` is larger than the stage-0 limit of 1 GiB ``` ### slice parameter `` cannot be reassigned; assign its elements Seen in 2 test programs. ```lane nul f(wr []u8 s) { s = "x"; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:20: error: slice parameter `s` cannot be reassigned; assign its elements ``` ### slice parameter `` cannot be reassigned; it cannot be passed as `out` Seen in 1 test program. ```lane nul g(out []u8 d) { d = "x"; } nul f(wr []u8 s) { g(out s); } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:26: error: slice parameter `s` cannot be reassigned; it cannot be passed as `out` ``` ### slice parameter `` is passed as a pointer and a length; its address cannot be taken Seen in 2 test programs. ```lane nul f(wr []u8 s) { p := &s; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:26: error: slice parameter `s` is passed as a pointer and a length; its address cannot be taken ``` ### the address of this expression cannot be taken; it is not a variable, an element, a field or a dereference Seen in 4 test programs. ```lane nul main() { p := &1; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:19: error: the address of this expression cannot be taken; it is not a variable, an element, a field or a dereference ``` ### the array length `` is larger than the stage-0 limit of GiB Seen in 3 test programs. ```lane nul main() { [2000000000]u8 a; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: the array length `2000000000` is larger than the stage-0 limit of 1 GiB ``` ### the array length `` is negative Seen in 2 test programs. ```lane nul main() { [-1]u8 a; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: the array length `-1` is negative ``` ### the constant `` is too large to compute Seen in 30 test programs. ```lane N :: 1 << 127; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:8: error: the constant `1 << 127` is too large to compute ``` ### the enum value does not fit in `` Seen in 2 test programs. ```lane enum E { a } N :: u8(E(1000)); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:10: error: the enum value 1000 does not fit in `u8` ``` ### the left side of an assignment must be a variable, an element, a field or a dereference Seen in 1 test program. ```lane u32 f() { ret 1; } nul main() { u32 x = 1; f() = x; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:26: error: the left side of an assignment must be a variable, an element, a field or a dereference ``` ### the program has no `` function Seen in 1 test program. ```lane nul f() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln: error: the program has no `main` function ``` ### the range ..= is empty Seen in 1 test program. ```lane nul main() { u8 x = 1; match x { 5..=4 { } else { } } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:34: error: the range 5..=4 is empty ``` ### the range ..= overlaps an earlier pattern at Seen in 3 test programs. ```lane nul main() { u8 x = 1; match x { 1..=5 { } 5..=9 { } else { } } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:44: error: the range 5..=9 overlaps an earlier pattern at 5 ``` ### the range .. is empty Seen in 2 test programs. ```lane nul main() { u8 x = 1; match x { 5..3 { } else { } } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:34: error: the range 5..3 is empty ``` ### the range .. overlaps an earlier pattern at Seen in 3 test programs. ```lane nul main() { u8 x = 1; match x { 5 { } 1..10 { } else { } } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:40: error: the range 1..10 overlaps an earlier pattern at 5 ``` ### the shift count - is outside to Seen in 3 test programs. ```lane N :: 1 >> -1; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:8: error: the shift count -1 is outside 0 to 127 ``` ### the shift count is outside to Seen in 2 test programs. ```lane MAXC :: (1 << 126) - 1 + (1 << 126); MINC :: -(1 << 126) - (1 << 126); N :: 1 << 128; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:3:8: error: the shift count 128 is outside 0 to 127 ``` ### the target type of `` is not known here; use it where a pointer or a `` is expected, as in `` Seen in 6 test programs. ```lane nul main() { u32 a = 1; cast(&a); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:29: error: the target type of `cast` is not known here; use it where a pointer or a `usz` is expected, as in `*u8 p = cast(q);` ``` ### the type of this character is not known here; convert it, as in `` Seen in 1 test program. ```lane nul main() { c := 'a'; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:19: error: the type of this character is not known here; convert it, as in `u8('a')` ``` ### the type of this enum value is not known here; name the enum, as in `` Seen in 2 test programs. ```lane N :: .a; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:6: error: the type of this enum value is not known here; name the enum, as in `Color.red` ``` ### the type of this integer is not known here; convert it, as in `` Seen in 9 test programs. ```lane nul main() { a := 1; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:19: error: the type of this integer is not known here; convert it, as in `u32(1)` ``` ### the value is already matched by an earlier pattern Seen in 9 test programs. ```lane nul main() { u8 x = 1; match x { 1, 1 { } else { } } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:37: error: the value 1 is already matched by an earlier pattern ``` ### the variables of this function take more than the stage-0 limit of GiB Seen in 2 test programs. ```lane nul main() { [1073741824]u8 a; u8 b = 1; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:32: error: the variables of this function take more than the stage-0 limit of 1 GiB ``` ### the variant `` is already matched by an earlier pattern Seen in 3 test programs. ```lane enum C { red, green } nul main() { C c; match c { .red, .red { } else { } } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:35: error: the variant `C.red` is already matched by an earlier pattern ``` ### this call returns nothing, so there is no value to store Seen in 1 test program. ```lane nul f() { } nul main() { a := f(); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:32: error: this call returns nothing, so there is no value to store ``` ### this expression does nothing; an expression statement must be a call Seen in 7 test programs. ```lane nul main() { true; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: this expression does nothing; an expression statement must be a call ``` ### this is not a constant expression Seen in 10 test programs. ```lane N :: &5; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:6: error: this is not a constant expression ``` ### this is not a variable, an element, a field or a dereference Seen in 1 test program. ```lane nul g(out []u8 d) { d = "x"; } nul main() { []u8 t; g(out t.ptr); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:29: error: this is not a variable, an element, a field or a dereference ``` ### this `match` does not cover the variant `` of ``; name it or add an `else` arm Seen in 2 test programs. ```lane enum C { red, green, blue } nul main() { C c; match c { .red, .blue { } } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:19: error: this `match` does not cover the variant `green` of `C`; name it or add an `else` arm ``` ### this `match` does not cover the variants ``, `` of ``; name them or add an `else` arm Seen in 2 test programs. ```lane enum C { red, green, blue } nul main() { C c; match c { .red { } } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:19: error: this `match` does not cover the variants `green`, `blue` of `C`; name them or add an `else` arm ``` ### this `match` does not cover the variants ``, ``, `` of ``; name them or add an `else` arm Seen in 1 test program. ```lane enum C { red, green, blue } nul main() { C c; match c { } } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:19: error: this `match` does not cover the variants `red`, `green`, `blue` of `C`; name them or add an `else` arm ``` ### unknown escape `` Seen in 3 test programs. ```lane nul main() { u8 c = '\q'; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:21: error: unknown escape `\q` ``` ### unknown function `` Seen in 4 test programs. ```lane nul main() { f(); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: unknown function `f` ``` ### unknown module ``; import it with `` Seen in 3 test programs. ```lane nul main() { nope.T m; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: unknown module `nope`; import it with `use nope;` ``` ### unknown name `` Seen in 29 test programs. ```lane nul main() { b = 1; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: unknown name `b` ``` ### unknown type `` Seen in 4 test programs. ```lane nul main() { Missing m; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: unknown type `Missing` ``` ### variant `` is declared twice in `` Seen in 2 test programs. ```lane enum E { a, a } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:13: error: variant `a` is declared twice in `E` ``` ### `` cannot be applied to `` Seen in 49 test programs. ```lane N :: -true; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:6: error: `-` cannot be applied to `bool` ``` ### `` cannot be applied to ``; `` it to a typed pointer first Seen in 4 test programs. ```lane nul f(wr *nul p) { p += 1; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:20: error: `+=` cannot be applied to `*nul`; `cast` it to a typed pointer first ``` ### `` cannot be assigned Seen in 5 test programs. ```lane nul main() { [4]u8 a; a.len = 1; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:24: error: `.len` cannot be assigned ``` ### `` cannot be indexed Seen in 3 test programs. ```lane nul main() { u32 x = 1; u8 v = x[0]; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:33: error: `u32` cannot be indexed ``` ### `` cannot be sliced Seen in 1 test program. ```lane nul main() { bool x = true; []u8 v = x[0..1]; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:39: error: `bool` cannot be sliced ``` ### `` cannot convert `` to ``; it converts between pointer types, and between a pointer and `` Seen in 3 test programs. ```lane nul main() { *u8 p = cast(u32(3)); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:30: error: `cast` cannot convert `u32` to `*u8`; it converts between pointer types, and between a pointer and `usz` ``` ### `` does not fit in `` Seen in 34 test programs. ```lane nul main() { u8 a = -1; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:21: error: `-1` does not fit in `u8` ``` ### `` gives a pointer or a ``, but `` is expected here Seen in 2 test programs. ```lane nul main() { bool b = cast(usz(1)); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:27: error: `cast` gives a pointer or a `usz`, but `bool` is expected here ``` ### `` has no field `` Seen in 16 test programs. ```lane nul main() { u32 a = 1; b := a.len; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:31: error: `u32` has no field `len` ``` ### `` has no size Seen in 1 test program. ```lane N :: size_of(nul); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: `nul` has no size ``` ### `` has no variant `` Seen in 7 test programs. ```lane enum E { a } nul main() { E e = .b; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:20: error: `E` has no variant `b` ``` ### `` is a constant, not a type Seen in 2 test programs. ```lane N :: 1; nul main() { N x; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:14: error: `N` is a constant, not a type ``` ### `` is a constant, which has no address Seen in 2 test programs. ```lane N :: 3; nul main() { p := &N; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:20: error: `N` is a constant, which has no address ``` ### `` is a predeclared function and cannot be declared Seen in 57 test programs. ```lane cast :: 1; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: `cast` is a predeclared function and cannot be declared ``` ### `` is a predeclared type and cannot be declared Seen in 136 test programs. ```lane i8 :: 1; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: `i8` is a predeclared type and cannot be declared ``` ### `` is a type, not a constant Seen in 1 test program. ```lane rec A { u8 a; } N :: A; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:6: error: `A` is a type, not a constant ``` ### `` is a type, not a value Seen in 4 test programs. ```lane enum E { a } nul main() { x := E; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:19: error: `E` is a type, not a value ``` ### `` is a variable, not a constant Seen in 5 test programs. ```lane nul main() { u32 v = 1; K :: v; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:30: error: `v` is a variable, not a constant ``` ### `` is already declared Seen in 13 test programs. ```lane nul main() { u8 a; u8 a; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:20: error: `a` is already declared ``` ### `` is already declared in this module Seen in 7 test programs. ```lane N :: 1; N :: 2; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:1: error: `N` is already declared in this module ``` ### `` is larger than the stage-0 limit of GiB for one array Seen in 20 test programs. ```lane nul main() { [1073741824]u16 a; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: `[1073741824]u16` is larger than the stage-0 limit of 1 GiB for one array ``` ### `` is and does not fit in `` Seen in 2 test programs. ```lane rec A { [300]u8 a; } nul main() { u8 x = size_of(A); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:28: error: `size_of(A)` is 300 and does not fit in `u8` ``` ### `` is named by two arguments of one call, and one of them is passed as `out` Seen in 6 test programs. ```lane nul f(out []u8 d, []u8 s) { d = s; } nul main() { []u8 t; f(out t, t); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:31: error: `t` is named by two arguments of one call, and one of them is passed as `out` ``` ### `` is named by two arguments of one call, and one of them is passed as `wr` Seen in 33 test programs. ```lane nul f(wr u32 a, u32 b) { } nul main() { u32 x = 1; f(wr x, x); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:33: error: `x` is named by two arguments of one call, and one of them is passed as `wr` ``` ### `` is not a function Seen in 1 test program. ```lane nul main() { u32 a = 1; a(); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:25: error: `a` is not a function ``` ### `` is not a pointer, so it cannot be dereferenced Seen in 3 test programs. ```lane nul main() { u32 x = 1; *x = 2; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:25: error: `u32` is not a pointer, so it cannot be dereferenced ``` ### `` is not `pub` Seen in 37 test programs. ```lane use os; nul main() { u32 a = os.CHUNK; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:24: error: `os.CHUNK` is not `pub` ``` ### `` is too large for any integer type Seen in 3 test programs. ```lane nul main() { u64 a = 99999999999999999999; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:22: error: `99999999999999999999` is too large for any integer type ``` ### `` must be `` or `` Seen in 2 test programs. ```lane nul main(u32 a) { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: `main` must be `nul main()` or `i32 main()` ``` ### `` needs a pointer, found `` Seen in 1 test program. ```lane nul main() { usz p = 1; []u8 s = slice(p, usz(1)); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:40: error: `slice` needs a pointer, found `usz` ``` ### `` needs a typed pointer, not ``; `` it first Seen in 2 test programs. ```lane nul main() { *nul p = nil; []u8 s = slice(p, usz(1)); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:43: error: `slice` needs a typed pointer, not `*nul`; `cast` it first ``` ### `` needs operands of the same type, found an integer and `` Seen in 1 test program. ```lane N :: 1 == true; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:8: error: `==` needs operands of the same type, found an integer and `bool` ``` ### `` needs operands of the same type, found `` and an integer Seen in 2 test programs. ```lane N :: true == 1; nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:11: error: `==` needs operands of the same type, found `bool` and an integer ``` ### `` needs operands of the same type, found `` and `` Seen in 13 test programs. ```lane N :: u8(1) + u16(1); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:12: error: `+` needs operands of the same type, found `u8` and `u16` ``` ### `` needs pointers of the same type, found `` and `` Seen in 2 test programs. ```lane nul f(*u8 p, *u32 q) { usz d = p - q; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:34: error: `-` needs pointers of the same type, found `*u8` and `*u32` ``` ### `` needs two hexadecimal digits Seen in 2 test programs. ```lane nul main() { u8 c = '\x4'; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:21: error: `\x` needs two hexadecimal digits ``` ### `` on a pointer needs a `` or a pointer of the same type, found `` Seen in 1 test program. ```lane nul f(*u8 p, i32 n) { *u8 q = p - n; } nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:33: error: `-` on a pointer needs a `usz` or a pointer of the same type, found `i32` ``` ### `` on a pointer needs a ``, found `` Seen in 5 test programs. ```lane nul main() { u32 a = 1; p := &a; q := p + p; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:41: error: `+` on a pointer needs a `usz`, found `*u32` ``` ### `` returns nothing; `ret` takes no value Seen in 2 test programs. ```lane nul main() { ret 1; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:18: error: `main` returns nothing; `ret` takes no value ``` ### `` returns ``, but not every path ends with `ret` Seen in 14 test programs. ```lane i32 main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:1: error: `main` returns `i32`, but not every path ends with `ret` ``` ### `` returns ``; `ret` needs a value Seen in 2 test programs. ```lane i32 main() { ret; } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: `main` returns `i32`; `ret` needs a value ``` ### `` takes a library name in quotes Seen in 1 test program. ```lane @lib(kernel32) ext nul f(); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:16: error: `@lib` takes a library name in quotes ``` ### `` takes a pointer and a length Seen in 2 test programs. ```lane nul main() { *u8 p = nil; []u8 s = slice(p); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:41: error: `slice` takes a pointer and a length ``` ### `` takes a string literal naming the file Seen in 3 test programs. This program has several modules; all are shown, root module last. Module `main.ln`: ```lane nul main() { []u8 s = embed(1); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:29: error: `embed` takes a string literal naming the file ``` ### `` takes a type name Seen in 1 test program. ```lane N :: size_of(5); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:14: error: `size_of` takes a type name ``` ### `` takes argument, found Seen in 1 test program. ```lane use io; nul main() { io.print(); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:2:22: error: `print` takes 1 argument, found 0 ``` ### `` takes arguments, found Seen in 1 test program. ```lane nul f(u32 a, u32 b) { } nul main() { f(1); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:39: error: `f` takes 2 arguments, found 1 ``` ### `` takes no access modes Seen in 7 test programs. ```lane N :: size_of(wr u8); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:17: error: `size_of` takes no access modes ``` ### `` takes one string literal Seen in 2 test programs. This program has several modules; all are shown, root module last. Module `main.ln`: ```lane nul main() { []u8 s = embed(); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:28: error: `embed` takes one string literal ``` ### `` takes one type name Seen in 3 test programs. ```lane N :: size_of(); nul main() { } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:13: error: `size_of` takes one type name ``` ### `` takes one value Seen in 2 test programs. ```lane nul main() { *u8 p = cast(); } ``` Verified: the compiler refuses this program (exit code 1). Compiler output: ```text main.ln:1:26: error: `cast` takes one value ``` --- # Targets > Which instruction sets and operating systems Lane builds for, their executable formats, SIMD and how parity is tested. Every target gets ahead-of-time native code: no VM and no JIT. The ext declaration gives every target a C ABI in both directions, so Lane code can link into an existing app or engine. The order and timing of the targets are on the roadmap. | Target | Executable format | SIMD | How parity is tested | |---|---|---|---| | x86-64 Windows | PE executable, and DLL for library output. | AVX2 (8 f32 lanes) and AVX-512 (16 lanes). | The reference target: the 1668 test programs are built and run on it, and the expected stdout and exit codes are those of this target. | | x86-64 Linux | ELF: a static executable with no interpreter and no C library, built with --target linux. | As x86-64 Windows. | The test programs are built for this target, run on Linux, and their stdout and exit codes are compared with the same expected bytes (the exit status modulo 256). | | AArch64: macOS, iOS, Linux, Android, Windows | Android: ELF shared library. iOS: a Mach-O object, linked and signed by Xcode. Linux: a static ELF executable with no C library, built with --target linux-arm64. macOS: a Mach-O executable with an ad-hoc signature, built with --target macos-arm64. Windows: not specified. The roadmap has the state of each. | NEON (4 f32 lanes). | The same test programs built for this target and checked against the same expected bytes. | | WebAssembly: wasm32 and wasm64, with SIMD128 | A wasm module (32-bit or 64-bit memory), a generated JavaScript loader and an HTML page (lane build --target web). Browser APIs are reached as ext imports. Lane does not compile to JavaScript source. | SIMD128 (4 f32 lanes), for both pointer widths. | The same test programs, with the same expected bytes, run under node and under wasmtime, for both pointer widths. | | RISC-V 64 with RVV | Linux: a static ELF executable with no C library. The roadmap has the state. | RVV, the RISC-V vector extension. | The same test programs, with the same expected bytes. | | SPIR-V | SPIR-V modules, from a pure subset: no pointers, function pointers, asm, par or recursion. | Compute shaders: vec loops over soa data are expressible as compute shaders. | Shader functions are testable on the CPU against the same expected values. | | 32-bit targets | Not specified. | Not specified. | The same test programs, with the same expected bytes. | Parity between targets is checked by building the same test programs for every target and comparing the program's output and exit code with the same expected bytes. Float code is strict by default, so results are bit-identical on every target (section 8.3 of the specification). --- # Roadmap > The planned order of work on Lane, with the state of each item. The order is the planned order of work: finished items first, then work under way, then the next items, then the rest. States are the state of each item on the date below, in the development compiler; the Downloads page offers the latest published release. This one data file feeds the page, its Markdown version and llms-full.txt. Updated 2026-10-28. ## Done so far - Language specification - Standard library written in Lane: io, fmt, mem, os, bufio and float - A test runner written in Lane, which runs the 1668 programs behind these docs ## Planned order | # | Item | State | Notes | |---|---|---|---| | 1 | Self-hosting | Done | The Lane compiler is written in Lane and compiles itself, on Windows, on Linux and on macOS (arm64). | | 2 | Floats: f32 and f64 | Done | Strict IEEE arithmetic at both optimization levels, with a native square root on every target. | | 3 | Position-independent executables | Done | Windows executables are built for address-space randomization and carry a header checksum; --resources adds an icon, a manifest and version information. | | 4 | Visual scripting | Done | Edit a program as a node graph side by side with its text, with the same checks and the same generated code. The program tree commands (tree, print, build --tree, nodes) are released. | | 5 | Inlining | Done | Small functions are inlined into their callers at -O1. | | 6 | Contracts | Done | assume lines and test examples on functions. The examples run during builds for every target, a failing one fails the build, float results can be stated exactly, and exported library functions can carry examples. Using assume facts in the optimizer is planned. | | 7 | x86-64 Linux | Done | Static executables that need no C library, built with --target linux. | | 8 | The compiler on Linux | Done | The compiler itself runs on Linux and builds itself to the same result as on Windows. | | 9 | Optimization on every processor family | Done | x86-64 builds at -O0 and -O1; AArch64 and RISC-V 64 build at -O1. Floats are optimized on x86-64. | | 10 | defer | Done | A statement that runs when its scope ends, for owned resources. | | 11 | Implicit lossless number conversions | Done | A value converts to a wider type without a cast when no information can be lost. | | 12 | Compile-time errors for impossible constants | Done | Integer division by a constant zero is an error, and so is any constant that is infinity or NaN. | | 13 | A faster compiler | In progress | Target: one million lines to a runnable executable in under one second on one core without optimization, and in under three seconds at full optimization. Dated figures are on the measurements page. | | 14 | Register allocation | In progress | Values live in registers instead of memory. | | 15 | Loops as fast as hand-written code | Next | At -O1, values a loop reuses stay in registers, divisions by powers of two become shifts, conditions branch directly, counters step in one instruction and calls to small functions no longer save and reload values around the call, so scalar loops run as fast as the same algorithm written by hand. | | 16 | Lane Explorer | In progress | The compiler in the browser: source on one side, the generated code for each target on the other. In progress: a result for every contract line, so that each example shows as passed or failed. | | 17 | WebAssembly: wasm32 and wasm64, with SIMD128 | In progress | wasm32 and wasm64 modules build with the same results as x86-64, and floats are done on both. Native SIMD128 code is still to come. | | 18 | Library output | In progress | Windows x86-64 libraries are done. In progress: a WebAssembly library mode, so that a host such as a game engine can embed Lane code. Linux shared libraries are planned. | | 19 | SIMD vectors | In progress | Fixed-width vector types and operations are done, including vectors in optimized code (-O1) and a native square root. In progress: AVX2 images. | | 20 | Exact math.fmod and math.wrap | In progress | Floating-point remainders with identical bits on every target. The % operator stays an error on floats. | | 21 | Files and processes in the standard library | In progress | Done on Windows. In progress: the file system on Linux. macOS and the browser follow. | | 22 | AArch64: macOS, iOS, Linux, Android, Windows | In progress | Linux and macOS (arm64) are done, with integers and floats; the compiler builds itself on macOS. iOS, Android and Windows on ARM remain. | | 23 | RISC-V 64 with RVV | In progress | Linux programs build with integers and floats, with -O1. The RISC-V vector extension remains. | | 24 | Faster test runs | In progress | A batched test runner and faster continuous integration, so the test programs run in less time. | | 25 | Threads | Next | Threads in the language, running on a thread pool that the host program provides. | | 26 | Asynchronous I/O | Next | await and job handles, so that file and network calls never block the main thread. | | 27 | File mocks for tests | Next | Fixture files and a fake event queue, so that functions that read and write files have examples. | | 28 | Compile-time evaluation | Next | Calls to suitable functions are evaluated while compiling, and recursion is turned into loops by the compiler. | | 29 | The I/O event queue, sockets and windows | Next | One queue for keys, mouse, windows, timers and network events, with sockets and native windows. | | 30 | The memory API and opt-in safety checks | Next | Virtual memory, arenas and pools in the standard library, and safety checks a program asks for. The cost of zero-initialising variables has been measured, to decide when the compiler may skip it. | | 31 | The loop optimizer and auto-vectorizer | Next | Loop optimizations, automatic vectorization and scheduling, with a per-loop report. | | 32 | Removing the bootstrap compiler | Next | The compiler is built only from a pinned earlier build of itself, with no other toolchain in the build. | | 33 | Windowed programs on Windows | Planned | A program can be built as a windowed program, so it starts without a console window and opens faster from Explorer or a shortcut. | | 34 | Syntax highlighting | Planned | A TextMate grammar for editors, and highlighting and language detection for Lane files on code-hosting sites. | | 35 | Native f16 | Planned | Half precision with the same results on every processor. | | 36 | The calculator showcase | Planned | A first small program that shows the language end to end. | | 37 | Coverage and profiling | Planned | Line and branch coverage and per-function timing, in builds that ask for them. | | 38 | Generics | Planned | Compile-time type and value parameters. | | 39 | Data-parallel loops, packed types and text types | Planned | vec and par loops, packed types and text types. | | 40 | ECS storage | Planned | SoA and AoS as one keyword for entity-component data. | | 41 | Incremental builds | Planned | Rebuild only what changed. | | 42 | lane watch | Planned | A long-running mode that keeps an executable ready and answers questions about the program. | | 43 | Hot reload | Planned | Change the functions of a running program, for game engines. | | 44 | The $12 server | Planned | A complete HTTP and JSON API server, built for the public "$12 Server Challenge". | | 45 | SPIR-V shaders | Planned | | | 46 | One language for every application | Planned | Complete applications on every platform written only in Lane: windows, a GPU-drawn UI and layout engine, input, files, network, audio, and desktop and mobile packaging, with no other language or framework in the build. | | 47 | 32-bit targets | Planned | Nice to have. | | 48 | Normalized types un8, un16, sn8, sn16 | Planned | Unorm and snorm values in 8 and 16 bits. | | 49 | Machine-learning number types | Planned | bf16, FP8 and quantized integers. | --- # Measurements > Every number on this site and how it was measured, and how Lane compiles itself. All figures are from one machine: i7-13700KF (24 threads), Windows 11, shared with other work unless a figure says otherwise. Single runs vary on a shared machine; ranges are given where they were measured. ## How Lane compiles itself Lane compiles itself in a chain. A bootstrap compiler builds the compiler written in Lane (A); A builds it again (B); B builds it again (C). The test of the whole chain is the fixpoint: A, B and C are the same bytes. Once that holds, the bootstrap compiler is frozen as the seed, and every new feature is written only in Lane. ## Headline figures ### One million lines, built in memory on one thread Measured, 2026-10-18. **1,105 ms** (the compiler written in Lane, without optimization). The whole build of a generated program: one million one-line functions, 56 MiB of source, a 128 MiB executable, on one thread, without optimization (-O0). It is the sum of the in-memory build phases (load and parse, collect, compile, layout) and does not include writing the executable to disk. Best of 5 interleaved rounds. Goal, not a result: The project goal is under 1,000 ms. ### The same program on 16 threads Prototype, 2026-10-14. **225 ms**. Best of 5 builds of the same one-million-line program (58.8 MB of source, 1,000,010 functions, a 134,892,544-byte executable) with the front end, declaration phases, code generation and image write running on 16 threads with chunks taken from a queue. A scratch prototype, not part of any release. The one-thread build took 1,789 to 1,801 ms in the same session, and the prototype's executable was byte for byte the same at every thread count tried (1 to 32). Taken in a quiet window, with the machine under 20 percent load. ### The compiler builds itself Measured, 2026-10-15. **18 ms**. The compiler written in Lane building its own source (628 functions in 29 modules) in memory, best of 3, one thread. It does not include writing the executable to disk or starting the process. ### The compiler reproduces itself byte for byte Measured, 2026-10-15. **617,984 bytes** (a 617,984-byte executable, built three times in a row with identical output). The bootstrap compiler builds the Lane compiler (A); A builds it again (B); B builds it again (C). A, B and C are the same 617,984 bytes. ### About 25% fewer tokens for well-tested code Estimate, 2026-10-14. **about 25%** (fewer tokens). A test is one line in the function's declaration, about 8 tokens, instead of a separate test function. The sample is one function with a precondition and four tests. It takes 92 tokens in Lane, against 152 to 168 tokens with conventional test frameworks. Tokens were counted with a proxy tokenizer, where each identifier, number, string or symbol counts as one. It assumes tests make up about half of well-tested code. The count covers test code only. It will be replaced by a measurement with a real model tokenizer. ## Front end throughput | Stage | Threads | Throughput | How measured | Date | |---|---|---|---|---| | Lex, compiler written in Lane | 1 | 334 MiB/s | Lane source repeated to 64 MiB, best of 10 | 2026-10-14 | | Lex and parse, compiler written in Lane | 1 | 161 to 170 MiB/s | A flat tree of arrays with no allocation per node | 2026-10-14 | ## Generated code Programs compiled by Lane and run, measured 2026-10-14: best wall time of 3 runs with process start included. | Program | Work | Time | |---|---|---| | xorshift | 300 million steps of a 64-bit xorshift generator | 0.436 to 0.438 s | | collatz | Collatz steps for every start below 2 million | 1.425 to 1.448 s | | primes | primes below 200,000 by trial division | 1.968 to 1.980 s | | sieve | primes below 10 million, in a 10 MB buffer from VirtualAlloc | 0.051 to 0.061 s | | histogram | fill, byte histogram and copy over 64 MiB | 0.310 to 0.311 s | | records | 30 update passes over one million 20-byte records | 0.105 to 0.106 s | | interpreter | 100 million instructions of an enum-and-match stack machine | 0.242 to 0.243 s | | memops | 8 rounds of mem.fill, an unaligned mem.copy and mem.eq over 64 MiB | 0.428 to 0.430 s | | read_file | os.read_file of a 64 MiB file and a newline count | 0.081 s | The code generator has no optimizer yet: every value is computed into a register and every variable and temporary lives in a stack slot. Each program returns a checksum that is compared with a reference result before its time is recorded. --- # Use cases > The tools and showcases Lane is designed to include, each linked to its item on the roadmap. The tools and showcases Lane is designed to include, each described as designed. Every entry links to its item on the roadmap, where the timing lives. ## Compile-time tests and contracts A function states what it requires with `assume` lines and shows what it returns with `test` lines, right in its declaration. The compiler runs them during the build, re-running only what changed, and writes the results to a binary report that `lane report` prints. What is different: A test is one line of the declaration, not a separate function, and every promise is tested on both sides: an input that satisfies it and one that must be refused. Roadmap: [Contracts](https://lane.trisgram.com/roadmap/#contracts) ## Test runner (lanetest) Builds each test case as a program and runs the cases in parallel, against any compiler and any target, comparing standard output, error output and exit code byte for byte. It writes JUnit output for CI. What is different: Corrupted twins of the cases prove that the runner cannot pass a wrong result, and the same cases are checked against every target with the same expected bytes. Roadmap: [Done so far](https://lane.trisgram.com/roadmap/#done) ## Profiling and coverage A profiling build records per-function call counts, time and memory, reads hardware counters for cache misses and branches, and reports line and branch coverage. What is different: Profiling and coverage are build options: a release build is byte-identical with or without the tooling, and contains none of it. Roadmap: [Coverage and profiling](https://lane.trisgram.com/roadmap/#coverage-profiling) ## lane watch: live builds and compiler queries On every save it builds a ready-to-run executable and reports all errors at once. Queries answer questions about signatures, references, layouts, the machine code of one function, and coverage. What is different: Built for editors and coding agents: every answer is plain lines, one fact per line, with no parsing step. Roadmap: [lane watch and agent queries](https://lane.trisgram.com/roadmap/#watch) ## Incremental and shared builds A content-addressed cache holds each function's compiled code and each test result, so a build redoes only what changed. The cache can be shared across a team's machines. What is different: The unit of caching is the function and the test result, not the file. Roadmap: [Incremental cache](https://lane.trisgram.com/roadmap/#incremental-cache) ## Hot reload Changes the functions of a running program as you edit them, so a game engine keeps its world loaded while the code changes. What is different: It works on the same per-function units as the incremental cache. Roadmap: [Hot reload](https://lane.trisgram.com/roadmap/#hot-reload) ## The $12 server A complete HTTP and JSON API server on SQLite with JWT authentication, built to enter the public "$12 Server Challenge": one vCPU and 2 GB of RAM. What is different: One small native executable whose data layout, threads and tests are written in the language itself, held to the challenge's own limits. Roadmap: [The $12 server](https://lane.trisgram.com/roadmap/#server) ## The calculator A native desktop calculator with exact decimal arithmetic. Every operation carries contracts, and the whole program is a tiny executable. What is different: The contracts are the specification: the test lines of each operation are its documentation and its oracle. Roadmap: [The calculator showcase](https://lane.trisgram.com/roadmap/#calculator) ## Database kernels Lane compiled as a library, with C-ABI exports and object files, so that a database engine can replace its SIMD kernels one at a time. What is different: One source for every ISA replaces a hand-written copy per architecture, and each kernel keeps a scalar reference that it is tested against. Roadmap: [Library output](https://lane.trisgram.com/roadmap/#library-output) ## Quantized ML kernels Kernels over `bf16`, FP8 and int4 data, with exact conversions to and from `f32` and SIMD bulk conversion. What is different: Every conversion rounds once, to nearest even, so a model gives the same bits on every processor. Roadmap: [Machine-learning number types](https://lane.trisgram.com/roadmap/#ml-number-types) ## Game engine code Data-oriented ECS storage in which SoA and AoS are one keyword on the array type, with packed lean types and threads in the language. Compact vertex data is a record of `sn8` normals and `un8` colours: 7 bytes where `f32` components would take 28. What is different: Changing a layout changes a type, not the code that uses it, and access modes make conflicts between threads checkable. Roadmap: [Game engine data](https://lane.trisgram.com/roadmap/#game-engine-data), [Normalized types](https://lane.trisgram.com/roadmap/#normalized-types), [Threads](https://lane.trisgram.com/roadmap/#threads) ## Web and GPU WebAssembly modules (wasm32 and wasm64) with a generated loader, and SPIR-V shaders written in a Lane subset. What is different: Records and math are shared between CPU code and shaders, and shader functions can be tested on the CPU. Roadmap: [WebAssembly](https://lane.trisgram.com/roadmap/#wasm), [SPIR-V shaders](https://lane.trisgram.com/roadmap/#spirv) --- # Lane Explorer > Write Lane as text or as a node graph and see the code generated for each instruction set, with the compiler running in your browser. The Explorer is a page of this site, [/explorer/](https://lane.trisgram.com/explorer/): the program as text and as a node graph, and the generated code for each instruction set. The compiler is one WebAssembly module that runs in a Web Worker in your browser, so nothing is uploaded and there is no server to store anything on. - Three views: Text, Text + graph and Graph. The graph shows the syntax tree of the same program as nodes, and editing it regenerates the canonical text; the compiler checks the tree exactly as it checks text. - A drop zone: drop a Lane file, several files or a folder on the page to open them. Nothing is uploaded. - A selector for the instruction set: x86-64, AArch64, wasm32, wasm64, RISC-V 64, SPIR-V. - An optimization level selector next to the instruction-set selector. It offers the levels the compiler lists for the selected instruction set and starts at the highest. - Each instruction in a listing is linked to the source line it came from and to the nodes of that line, and the other way round. - Diagnostics are listed above the generated code in every view, as plain lines: path:line:col: error: message, and are underlined in the editor. - A program is shared by a URL fragment that holds the compressed source, the instruction set and the optimization level. The page needs JavaScript. The compiler takes its input as an in-memory module map and answers with a listing; the interface is the same one the command line uses with build --asm --isa -O.