Error catalog — most common errors, exact fixes
Type mismatch
Section titled “Type mismatch”x: int = "hello" // expected int, found strFix: annotate correctly (x: str = "hello") or convert (x := int("hello") ?? 0).
Arg errors name the parameter: parameter `greeting` expects `str` .
Undefined variable / typo
Section titled “Undefined variable / typo”undefined variable `pritnln` // did you mean `println`?Fix: zz fix applies the safe rename; check selective-import names
(import shapes(Tokens) vs qualified shapes.Tokens).
Missing match arm
Section titled “Missing match arm”non-exhaustive match: missing `.IntLit` (or add a `_` arm)Fix: add the variant or _ => .... Guarded _ if cond does not count.
Bare payload pattern
Section titled “Bare payload pattern”.ok // type error: .ok always carries a payloadFix: .ok(_) to ignore, .ok(n) to bind. zz fix rewrites bare patterns.
Unused Result
Section titled “Unused Result”fs.write(path, data) // warning: unused ResultFix: match, ?, or _ := fs.write(...). Block tails are values (no warning);
loop tails and defer expressions do warn.
Dead arm
Section titled “Dead arm”Arms after _ / bare binding warn unreachable. Move the catch-all last or guard it.
Tuple dynamic index
Section titled “Tuple dynamic index”t[i] // compile errorFix: destructure ((a, b) := t) or literal index (t[0]). Out-of-range literals
are also compile-time.
Import errors
Section titled “Import errors”circular import: a imports b, b imports a→ extract sharedc.zz.- Two files under one namespace → alias one side (
import a as x). - Stale lock pin →
zz installrewrites from manifest (note names the source). param("typo")→ checker names valid params; fix the string.
Integer traps
Section titled “Integer traps”- Overflow wraps (never traps) — guard counters/money at the boundary.
1 / 0literal fails at check time; runtime divide-by-zero andINT64_MIN / -1error.- Negative shift count errors; shifts mask to
& 63(1 << 64is1). - Bitwise needs
intboth sides;~needsint.
HTTP / IO
Section titled “HTTP / IO”- Bare
.errtoprintlnaborts —matchit first. req.bodyis lossy text; binary needshttp.body_bytes(req)/read_bytes.join(dir, "/file.txt")losesdir— usejoin(dir, "file.txt").- Non-TTY
term.*fails soft.err("... not a tty")— gate withis_tty(exceptpoll). free_port()is TOCTOU — re-bind immediately, retry, tag testsserial.
Run zz fix for safe rewrites, zz check --format json for machine output.