Skip to main content

Diagnostics Code Reference

A quick-reference table for every stable diagnostic code emitted by the Zero compiler. Use zero explain <code> for deeper guidance on any specific code.

How to Read Diagnostics

Run zero check --json to get structured diagnostic output:

{
"schemaVersion": 1,
"ok": false,
"diagnostics": [
{
"severity": "error",
"code": "NAM003",
"message": "unknown identifier 'message'",
"path": "examples/hello.0",
"line": 2,
"column": 27,
"length": 7,
"expected": "visible local, parameter, function, or builtin",
"actual": "no visible symbol named 'message'",
"help": "declare the name before using it",
"fixSafety": "behavior-preserving",
"repair": {
"id": "manual-review",
"summary": "Inspect the diagnostic fields and choose a repair manually."
},
"related": []
}
]
}

Each diagnostic includes: code (stable identifier), message (what went wrong), location (path, line, column), expected/actual (the mismatch), help (suggested fix), and fixSafety (automation label).

Fix Safety Labels

Fixes carry safety labels so agents and tools know when they can act automatically:

LabelMeaning
format-onlyChanges only formatting, no behavioral impact
behavior-preservingPreserves program behavior, safe to apply
local-editConfined to the current local scope or file
api-changingChanges function signatures, exported names, package APIs, or call sites
requires-human-reviewRisky or ambiguous; show the plan but do not apply automatically

Code Reference

PAR - Parser

CodeMessageMeaningFix
PAR100parser syntax failureMissing braces, commas, malformed type argument lists, or other syntax errorsCheck the indicated token and surrounding structure; add missing delimiters or fix malformed syntax

NAM - Names

CodeMessageMeaningFix
NAM003unknown identifierA name is used before being declared in the current lexical scopeIntroduce a local binding, parameter, or import before this use
NAM004duplicate name / arity mismatchDuplicate names, wrong call arity, or generic type-name shadowingRename the duplicate, correct the argument count, or remove the shadowing declaration

TYP - Types

CodeMessageMeaningFix
TYP002type mismatchType mismatch in assignments, literals, returns, or type defaultsEnsure the expression matches the expected type; add explicit cast or annotation
TYP009mutable storage requiredWritable byte helpers (e.g. std.mem.copy) require mutable storageChange let to var for the destination binding
TYP010condition must be BoolA condition expression is not BoolUse a boolean expression or comparison operator
TYP011null requires Maybe contextnull used outside a Maybe<T> contextWrap with Maybe<T> or provide a typed default
TYP012break outside loopbreak used without an enclosing loopMove break inside a loop body or restructure control flow
TYP013continue outside loopcontinue used without an enclosing loopMove continue inside a loop body or restructure control flow
TYP014non-integer loop boundsRange loop bounds must be integer-compatibleUse integer expressions for loop range bounds
TYP015invalid integer literalInteger literal uses invalid digits, separators, radix prefixes, or suffixesFix the literal format; use valid digits and optional radix prefix (0x, 0b, 0o)
TYP016integer overflowInteger literal does not fit the expected primitive integer widthUse a wider type or reduce the literal value
TYP017invalid castas casts are limited to primitive numeric and byte char typesCast between compatible numeric types only
TYP018invalid char literalCharacter literal must contain exactly one byte or a supported byte escapeUse a single character or escape sequence like \n, \t, \\
TYP019invalid float literalFloat literal must use digits "." digits with an optional exponentAdd a decimal point; e.g. 1.0 instead of 1
TYP020float overflowFloat literal does not fit the expected primitive float widthUse f64 for larger values or reduce the literal
TYP021unsupported indexing targetIndexing, slicing, or indexed assignment on an unsupported targetUse a supported array, slice, or indexable type
TYP022non-integer indexIndex expressions and slice bounds must be integersUse integer expressions for indices and bounds
TYP023generic arity mismatchGeneric call type argument count mismatch, or type arguments on a non-generic functionMatch the number of type parameters; remove type args from non-generic calls
TYP024conflicting generic inferenceGeneric inference found conflicting concrete types for one type parameterMake arguments agree or pass explicit type arguments
TYP025inference failureGeneric type arguments could not be inferred from local call argumentsPass explicit type arguments: fn<Type>(args)
TYP026cyclic type aliasA type alias is duplicated, malformed, or cyclicPoint the alias at a concrete type or remove the cycle
TYP027recursive generic mutationRecursive generic call changes type argumentsEnsure recursive calls use consistent type arguments

BOR - Borrows

CodeMessageMeaningFix
BOR001borrow conflictLexical borrow conflicts; JSON includes borrowTrace.activeBorrows with details on each borrowed rootReorder borrows, reduce borrow scope, or clone the value
BOR002reference escapeReference-origin escapes, including references returned from calls or stored through mutable parameter storageReturn owned values instead of references, or restructure to avoid escape

OWN - Ownership

CodeMessageMeaningFix
OWN001use after moveOwned value used after being moved, or generic containers owning unconstrained generic payloadsClone before move, reorder usage, or use references where appropriate

ERR - Error Flow

CodeMessageMeaningFix
ERR002missing error in setCaller's explicit error set is missing an error raised by a calleeAdd the missing error to the raises set: raises [NotFound, Io, ...]
ERR003unchecked fallible callA fallible call was used without check or rescueAdd check to propagate, or rescue to handle locally

TAR - Targets

CodeMessageMeaningFix
TAR001unknown targetThe requested target name is not in zero targetsCheck available targets with zero targets and use a valid name
TAR002missing capabilityThe selected target does not provide a capability required by the programBuild for a target with the required capability or use target-specific entry points

IMP - Imports

CodeMessageMeaningFix
IMP001unknown importUnknown package-local import pathCheck the import path; use repair id fix-import-path
IMP002import cyclePackage-local import forms a cycleRestructure imports to break the cycle
IMP003duplicate exportDuplicate public exports across imported modulesRename or remove one of the conflicting exports

PKG - Packages

CodeMessageMeaningFix
PKG001missing zero.jsonA local package dependency path does not contain zero.jsonEnsure the dependency directory contains a valid zero.json manifest
PKG002package cyclePackage dependencies form a cycleRestructure dependencies to break the cycle
PKG003version conflictOne package name resolves to conflicting versionsAlign dependency versions across manifests
PKG004unsupported targetA package dependency does not support the selected targetUse a compatible target or find an alternative dependency

IFC - Interfaces

CodeMessageMeaningFix
IFC001unknown constraintAn interface constraint is unknown or a concrete type argument has no static type bodyImport the interface or provide a type with the required static body
IFC002missing methodA constrained concrete type is missing a required static interface methodImplement the required method on the concrete type
IFC003wrong parameter countA concrete static method has the wrong parameter count for an interfaceMatch the interface's method signature parameter count
IFC004wrong return typeA concrete static method has the wrong return type for an interfaceMatch the interface's method return type
IFC005wrong parameter typeA concrete static method has the wrong parameter type for an interfaceMatch the interface's method parameter types

STC - Static Values

CodeMessageMeaningFix
STC001unsupported static typeA static value parameter uses an unsupported non-integer typeUse an integer type for static value parameters
STC002non-literal static argA static value argument is not an integer literal or deterministic top-level constUse an integer literal or a top-level const value
STC003static value conflictAn explicit static value argument conflicts with the value carried by an annotated typeRemove the explicit argument or adjust the type annotation

Other

CodeMessageMeaningFix
BLD002bad manifestBad project manifest or unsupported manifest target shapeFix the zero.json manifest structure or remove unsupported target configuration
ABI001unsupported C ABIUnsupported C ABI export or extern layout surfaceUse supported ABI-compatible types; check extern declarations
CIMP003host path leakA foreign-target C dependency would use host include/library paths or host pkg-configUse package-relative vendored headers/libraries or configure the target sysroot
CIMP004missing C functionAn extern C call names a function missing from the imported header or uses an unsupported C ABI typeEnsure the function is declared in the header; use compatible C types
CIMP005missing C link planAn extern C call is missing matching C link metadata or uses an unsafe system library nameAdd matching c.libs.* entry in zero.json with headers and lib/link
SHM001inference failureA generic type method call cannot infer inherited type/static parametersPass explicit type or static arguments
SHM002conflicting SelfArguments to a generic type method imply conflicting Self instantiationsEnsure arguments agree on the same Self type
RCV001unknown methodA receiver-style call names an unknown method or a static method without selfCheck method name; use instance methods for receiver calls
RCV002addressable receiverA receiver-style call needs an addressable receiver, or a mutable receiver for mutref<Self>Use a variable binding as receiver; use var for mutable receivers
FLD001unknown fieldA type literal includes an unknown fieldRemove the field or check the type definition
FLD002missing required fieldA type literal omitted a required field that has no defaultAdd the required field with a value
MEM001malformed MaybeMalformed memory type forms such as Maybe without its required type argumentAdd the type argument: Maybe<T>
MEM002unguarded Maybe readA Maybe<T>.value read that has not been proven present by a visible .has guardAdd a .has guard, check, or rescue before reading .value
MET001unsupported metaA parsed meta expression requested compile-time behavior not yet supportedAvoid unsupported meta expressions; use runtime alternatives
PUB001missing API metadataA public declaration omitted required explicit API type metadataAdd explicit type annotation: pub const name: Type = value
MAT004payload mismatchA match arm can bind a payload only for a choice case that carries oneMatch the payload pattern to cases that carry payloads

Common Fix Plans

1. Missing Variable Declaration (NAM003)

Problem: Using a name before declaring it.

pub fn main(world: World) -> Void raises {
check world.out.write(message) // 'message' not declared
}

Fix: Introduce a local binding before use.

pub fn main(world: World) -> Void raises {
let message: String = "hello from zero\n"
check world.out.write(message)
}

2. Unchecked Fallible Call (ERR003)

Problem: A fallible function call without check or rescue.

let file: owned<File> = std.fs.createOrRaise(fs, ".zero/out.txt")

Fix: Use check to propagate errors and declare the error set.

fn createFile(fs: owned<Fs>) -> owned<File> raises [NotFound, TooLarge, Io] {
return check std.fs.createOrRaise(fs, ".zero/out.txt")
}

3. Type Inference Conflict (TYP024)

Problem: Generic call where T would need to be both i32 and u8.

fn first<T: Type>(left: T, right: T) -> T {
return left
}
let value: i32 = first(1, 2_u8)

Fix: Make arguments agree or pass explicit type arguments.

let value: i32 = first<i32>(1, 2)

4. Missing API Metadata (PUB001)

Problem: Public constant without explicit type annotation.

pub const answer = 42

Fix: Add the required type annotation.

pub const answer: i32 = 42

5. Cross-Target C Dependency (CIMP003)

Problem: Foreign-target build tries to use host include paths or pkg-config.

zero build --json --target linux-musl-x64 my-package

Fix: Use package-relative vendored headers/libraries or configure the target sysroot. Do not rely on host paths for cross-compilation.

Further Reading