Appendix B. Error codes

<!-- coax-release:current:start --> Current compiler: coax0 0.52.0. Status inventory schema: 1. <!-- coax-release:current:end --> This appendix lists every error code the current compiler can report. The tables below are the output of coax explain --all --markdown, which prints the compiler's own table from coax/src/errors.cpp; when that table changes, regenerate this appendix from it rather than editing the rows by hand. In a terminal, coax explain CODE prints one entry:

shell
$ coax explain E0303E0303: name already declared; no shadowing  Every local name in a procedure is unique among the names in scope. Coax has no shadowing, so a name always means one thing.

Codes are stable: a code keeps its meaning, and a retired code is never reused, so the tables include the retired ones too.

The E0413 description below refers to the default checks-c ABI1. Explicit checks-c --verification-abi 2 supports admitted finite #forall properties. Unsupported bodies still refuse, and both ABIs retain authority checks.

The first two digits after the E give the stage that reports the error:

PrefixStageWhere to read more
E01LexerChapter 4
E02ParserChapter 4
E03CheckerChapter 4
E04Compile-time evaluation and checksChapters 9 and 11
E05Protobuf descriptor importsChapter 18
E06Source-unit compositionChapter 10
E07Device code (coax cuda, coax metal-compute, coax spirv)Chapter 17
E08Generic structsChapter 8
E09Tagged values and effect declarationsChapters 7 and 14

Chapter 4 explains how to read a diagnostic, and Chapter 27 shows which part of the compiler produces each stage's errors. With --diagnostics json, each diagnostic is one JSON object per line on stderr. It carries a schema, severity, code, message, source span, notes and proposed fixes.

E01xx: lexer

CodeMeaningWhat to do
E0101block comment is never closedA /* comment has no matching / before the end of the file. Block comments nest, so every / inside needs its own */.
E0102retired in 0.3.0Was: floating-point literals are not supported. Floats arrived in 0.3.0.
E0103number has no digits after its base prefix0x and 0b must be followed by at least one digit of that base.
E0104integer literal does not fit in 64 bitsInteger literals go up to 18446744073709551615 (the u64 maximum). Where the literal is used, it must also fit that type.
E0105unknown escape in a stringStrings support \n \t \r \0 \ and ". Unicode and hex escapes are planned.
E0106string is never closedA string ends with a " on the same line. Strings cannot span lines yet.
E0107non-ASCII character outside a string or commentIdentifiers and operators are ASCII. UTF-8 text belongs in strings and comments.
E0108unexpected characterThe character starts no token in Coax.
E0109bad floating-point literalThe literal rounds to infinity (the largest f64 is about 1.8e308, the largest f32 about 3.4e38), or it is followed by something other than an f32 or f64 suffix.
E0110invalid character literalA character literal is one ASCII character or escape in single quotes ('a', '\n', '''). It is an integer literal holding that byte, so it fits u8.
E0111lexer source or storage limitSource must fit signed 32-bit byte offsets and one-based EOF locations. Native lexer buffers must meet the Coax capacity contract.

E02xx: parser

CodeMeaningWhat to do
E0201expected a tokenThe parser needed a specific token here, usually ';', ')' or '}'. For a missing ';' the caret points right after the previous token.
E0202expected a typeA type is a name, a fixed array '[N] T', a view '[] T', an optional 'T?', or an admitted parameterized type such as Result(T,E). Parentheses group a type before an optional suffix.
E0203comparisons cannot be chaineda < b < c is rejected rather than given a surprising meaning. Write a < b && b < c.
E0204reserved word not supported yetThe word is reserved for a planned feature, such as using or enum_flags. coax0 refuses it rather than guessing what it means.
E0205expected an expressionA value was needed here: a literal, a name, a call, or a parenthesized expression.
E0206local declarations with :: are not supportedConstants, procedures and types are declared at the top level in coax0.
E0207cannot assign to this expressionOnly a variable, a struct field or an element (a[i]) can be assigned.
E0208expected a nameA parameter, field, member or loop variable name was expected here.
E0209expected a module name after #importWrite #import "Basic";
E0210directive not supported hereThe directive is unknown or not implemented in this position. Procedures accept #export_c, #foreign and #inline; #inline is refused with either of the other two and on main and recursive procedures. Files accept #import and #assert; expressions accept #run.
E0211retired in 0.2.0Was: only procedures can be declared at the top level. Top-level constants arrived in 0.2.0.
E0212global variables are not supportedTop-level mutable state is not part of coax0. Use constants, or pass state explicitly.
E0213expected a top-level declarationThe top level holds #import, #assert and declarations 'name :: ...'.
E0214unknown cast modifierThe only modifier is trunc: cast,trunc(u8) x keeps the low bits instead of checking that the value fits.
E0215struct literal needs a struct nameWrite the struct's name before .{ }: Point.{x = 1, y = 2}. Inferred literals are planned.
E0216ranges are half-openCoax ranges are written lo..<hi and include lo but not hi. '..' alone is not a range.
E0217array literal needs a fixed array typeWrite the type first: [3] int.[1, 2, 3].
E0218a range loop has one variablefor i: 0..<n { } has a counter only. Index variables belong to loops over arrays, views and strings.
E0219enum needs an underlying typeAn enum names its integer width: Outcome :: enum u8 { ... }. The width is part of its layout.
E0220malformed check#test takes a name string and a block: #test "refunds never exceed payment" { ... }. #forall takes one or more bindings, each a type or a lo..<hi range, then a block: #forall a: u8, b: 0..<10 { ... }. #steps N before the block gives the check its own budget of N steps, a positive integer literal: #test "the world builds" #steps 150000000 { ... }.
E0221parser resource limitThe Coax parser requires an EOF-terminated lexer token stream, caller-owned indexed-tree storage and at most 128 active recursive grammar entries. Reduce syntax nesting or supply the capacities returned by PS_caps. No partial syntax tree is admitted after a failure. A build above 96 entries gets a near-limit note.
E0223malformed struct parameter listA generic struct lists its parameters as $NAME, each once, separated by ',': Pair :: struct($T) { a: $T; b: $T; } or Box :: struct($T, $N) { items: [$N] $T; }.
E0222qualified name reaches through an aliasA qualified name is one module alias and one declaration: hud.Slot, hud.frame(x). Aliases are not reexported, so a.b.Name is refused; load that module with its own alias.
E0224malformed #run_steps#run_steps N; declares the compile-time step budget of the whole compilation, N a whole number from 1 through 250000000: #run_steps 250000000;. A file declares it at most once, and only the entry file's applies: a loaded file's is ignored, so a library declares what it needs when checked alone and never raises the budget of a program that loads it. --run-steps N on the command line overrides it.
E0225a spelling from another languageThe code uses a spelling from C, C++, Rust, Go, JavaScript, Python or Jai that Coax writes another way, and the message names the Coax spelling. Locals are declared with x := 1; or x: int = 1; (no let, var or const), procedures with add :: (a: int) -> int { }, types with Point :: struct { x: int; }, constants with N :: 3;. Casts are cast(T) x, the conditional expression is ifx c then a else b, loops are for i: 0..<n { } and while c { }, and x += 1 replaces x++. There are no pointers: pass an array as a view with name[..]. Integers are s8..s64 and u8..u64 (int is s64), floats f32 and f64, booleans true and false, an empty optional null. print("%\n", x) prints with #import "Basic";, and #assert c; asserts. coax vocab WORD prints the Coax spelling of a word from another language.

E03xx: checker

CodeMeaningWhat to do
E0301type not supported yetThe type is in the plan (spec 6.2) but coax0 does not implement it, for example dynamic arrays '[..] T' or vectors.
E0302unknown typeNo built-in type, struct or enum has this name.
E0303name already declared; no shadowingEvery local name in a procedure is unique among the names in scope. Coax has no shadowing, so a name always means one thing.
E0304retired in 0.52.0Was: name is already a procedure. A local, parameter or loop variable may share a procedure's name: procedures are not values, so name(...) calls the procedure and a bare name is the local.
E0305procedures are not valuesProcedure values, callbacks and procedure types such as (int) -> int are planned. Call the procedure instead: a bare name is a local, parameter or constant, never a procedure. To pick a procedure at run time, pass an enum that names the choice and branch on it where the call happens: Op :: enum u8 { add; mul; } apply :: (op: Op, a: int, b: int) -> int { if op == Op.add { return a + b; } return a * b; }.
E0306name is not declaredNo local, parameter or constant with this name is in scope here.
E0307'-' needs a signed integer or a floatUnsigned integers have no negation. Subtract from a value, or use a signed type.
E0308'!' needs a boolThere is no truthiness. Compare instead: x == 0.
E0309arithmetic needs two numbers of one type+ - * / need two integers or two floats of the same type; % needs integers. There are no implicit conversions, so f32 and f64 (or s32 and int) do not mix: cast one side. The fix line names the cast, such as cast(f32) b; when the result's type is known, it keeps the side that already has it. An untyped literal takes the other side's type by itself.
E0310ordering needs two numbers of one type< <= > >= compare two integers or two floats of the same type.
E0311cannot compare these values== and != need two values of one type. Structs, arrays and views are compared field by field or element by element, by you.
E0312boolean operator needs two bools&& and || take bools and short-circuit.
E0313retired in 0.52.0Was: print needs Basic. Basic is imported by default, so print needs no #import; #import "Basic"; is still accepted.
E0314not a procedureA constant or variable was called like a procedure.
E0315procedure is not declaredNo procedure has this name. Procedures may be declared after they are used.
E0316wrong number of argumentsThe call passes a different number of arguments than the procedure declares.
E0317argument has the wrong typeEach argument must have its parameter's type exactly. An array is passed as a view with name[..].
E0318print needs a format stringprint("text\n"); the format comes first.
E0319print's format must be a literalThe format is checked while compiling, so it must be a string literal.
E0320format slots and values differEach % in the format takes one value. Write %% for a percent sign.
E0321cannot print nothingThis call returns no value, so there is nothing to print.
E0322value is not usedAn expression statement must do something: call a procedure, or assign its value. To evaluate an expression and drop its value on purpose, write _ = expression;.
E0323result is not usedThe procedure returns a value that is dropped. Use it, store it, or drop it on purpose with _ = f(...);. '_' names nothing: _ = e; and _ := e; evaluate e and drop the value, as often as you like. A Result is never dropped this way; handle it.
E0324cannot initialize from nothingThe call returns no value, so it cannot initialize a variable.
E0325initializer has the wrong typeThe variable's declared type and its initializer differ. There are no implicit conversions.
E0326compound assignment needs a number+= -= *= /= need a number target; %= &= |= ^= <<= >>= need an integer.
E0327assigned value has the wrong typeThe value's type differs from the target's.
E0328missing return valueThe procedure declares a result, so return needs a value.
E0329procedure returns nothingA value is returned from a procedure without '-> T'.
E0330returned value has the wrong typeThe value differs from the declared result type.
E0331condition must be boolif, while and ifx take a bool. Compare explicitly: x != 0.
E0332module imported twiceRemove the second #import.
E0333unknown modulecoax0 has one module, Basic.
E0334procedure declared twiceThere are no overloads yet; every procedure name is unique.
E0335name is a builtinprint (with Basic) and type_name are reserved by the compiler.
E0336no maincoax run and coax build make a program, which needs main :: () { }. A file with no main is a library: coax test, coax check, coax mutate and coax c take it as one without --library, and coax lib builds it.
E0337main has the wrong signaturemain takes no parameters and returns nothing in coax0.
E0338missing returnSome path reaches the end of a procedure that must return a value.
E0339too many generic instancesA program may make 256 generic instances, or one per 8 syntax nodes in a program of more than 2056: one per generic procedure or struct and distinct binding of its parameters. The message names the limit and lists the generics with the most instances, at their declarations; a build above three quarters of it gets a near-limit note with the same list. A chain of generic uses that binds ever larger types never ends; break it with a concrete type.
E0340constant dependency cycleConstants may refer to each other in any order, but not in a circle.
E0341constant has no valueA constant or #run must produce a value; a call returning nothing cannot.
E0342name is a constant, type or intrinsicA local cannot take the name of a constant, struct, enum or intrinsic.
E0343type_name needs one valuetype_name(x) takes exactly one expression with a value. It is checked but never run.
E0344cannot assign a constant or parameterConstants never change. Parameters are immutable: copy one into a local to update it.
E0345duplicate or conflicting constantThe constant's name is already a constant, procedure or intrinsic.
E0346#assert needs boolThe asserted expression must be a bool, at the top level and in a statement.
E0347constant dependencies too deepConstant type resolution is bounded at depth 64.
E0348type parameter bound twiceThe arguments of one call bind each $T once: the first typed argument whose type uses $T binds it, and every other one must have that same type; an untyped literal for a bare $T takes the bound type. Pass the same type, or convert one with cast.
E0349argument does not have the parameter's shapeA parameter written [] $T binds $T from a view, so its argument must be a view (pass name[..] for an array); one written [$N] T or [4] T binds or checks a fixed array's length, so its argument must be a fixed array of that length.
E0350value does not fit its typeUntyped literals take the type their use needs, if the value fits: x: u8 = 300 does not. A float literal cannot become an integer. Use a wider type, or cast,trunc to keep the low bits.
E0351no such field or memberThe struct has no field, or the enum no member, with this name. Arrays, views and strings have .count.
E0352duplicate field or memberA field or member name appears twice in a declaration or a literal.
E0353struct contains itselfA struct cannot hold itself by value; its size would be infinite. Hold it through a view, or by index.
E0354a type is not a valueA struct or enum name was used as a value. Make a struct with Name.{ }, or name an enum member with Name.member.
E0355cannot index or slice thisOnly arrays, views and strings can be indexed and sliced.
E0356index must be an integerIndices and slice bounds are integers of any width. They are checked against the length at run time.
E0357array length not known while checkingAn array length is a positive integer known while checking: a literal, a constant, size_of, or arithmetic on them. Lengths computed by #run are planned.
E0358array literal has the wrong count[N] T.[...] gives exactly N elements.
E0359cannot assign thisThe target is a loop variable, a string byte, .count, or a temporary. Strings are immutable; copy the bytes into [N] u8 to change them.
E0360break or continue outside a loopbreak and continue belong inside while and for.
E0361deferred code cannot leave its blockA deferred statement runs while its block exits, so it cannot return, break or continue out of it.
E0362invalid castcast converts between numbers, and between enums and integers. cast,trunc converts between integer types only.
E0363invalid enum valueEnum values are integers known while checking, fit the underlying type, and are distinct.
E0364cannot loop over thisfor takes a half-open range lo..<hi of one integer type, an array, a view, or a string.
E0365ifx branches differBoth branches of ifx produce a value of the same type.
E0366a view needs a variable arrayA view [] T borrows an array's storage and may write through it, so the array must be a local variable. To only read a constant or a parameter, borrow it as a read-only view: type the receiving parameter or variable [] const T, as in sum :: (v: [] const int) -> int and sum(K[..]). To write, copy it into a local first. A temporary (a call's result or an array literal) has no storage to borrow: put it in a local, then take its view.
E0367field or element has the wrong typeThe value given for a struct field, field default or array element has a different type.
E0368type and value parameters share a nameA $NAME is either a type parameter ($T, written as a type) or a value parameter ($N, written as a fixed array length [$N] T) in one procedure, not both. Give the length its own name.
E0369invalid exportmain cannot be exported, and exported names cannot start with coax_, which the generated runtime uses.
E0370bit operation needs integers& | ^ need two integers of one type; << >> shift an integer by an integer amount from 0 to its width minus one.
E0371field name is reserved in CStruct fields keep their names in generated C and headers, so they cannot be C or C++ keywords or start with '_'.
E0372type name conflictsA struct or enum name is already used by another type, a procedure, a constant, or a built-in.
E0373enum base must be an integerAn enum's underlying type is one of s8..s64 or u8..u64.
E0374constant index out of boundsAn index written as a constant must be inside a fixed array's length. Indexes computed at run time are checked when they run.
E0375math or string intrinsic misusedsin cos tan exp log sqrt floor abs take one float, pow two floats of one type; len takes a string, array or view; byte_at takes a string and an index. Convert integers first: f64(x).
E0376procedure cannot cross the C boundaryA #foreign procedure passes integers, floats, bool and borrowed views of them, returns a scalar or nothing, and its name must be a valid C symbol that is not main and does not start with coax_.
E0377outside the Metal scalar profilecoax metal accepts f32 and bool values, if/else, locals and acyclic calls. Loops, strings, integers, f64, print, #assert and #foreign calls stay in the C library.
E0378byte intrinsic argument mismatchbytes_overlap takes byte views or strings. Float bit conversions take their matching f32/u32 or f64/u64 type. add_wrap, sub_wrap, mul_wrap, add_checked, sub_checked, mul_checked, add_sat, sub_sat and mul_sat take two integers of one type; rotl and rotr two u32 or two u64.
E0379#forall domain cannot be enumeratedA #forall binding must be nonempty: bool, a nonempty enum, an integer of at most 16 bits, or an increasing lo..<hi range of int constants. Test a wider type on a small instance: write the code so a smaller type or range exercises the same paths.
E0380procedure not exercised by a checkEvery procedure except main and #foreign imports must actually execute during an #authority check. Dead branches and pre-folded #run results do not count. Execution coverage is not a proof of the assertions.
E0381type checker resource limitThe Coax checker needs its caller-owned graph, type, local, diagnostic and text capacities and at most 256 active semantic entries. Reduce nesting or use CK_caps. When generic instances fill the node store (16 times the program's own nodes), the error lists the generics whose instances copied the most nodes. Failed checking never admits a partial typed tree. A build above 192 entries gets a near-limit note. Borrow analysis gives each declaration 2097152 steps in each pass and names the one that runs out; split it into smaller procedures. A declaration above three quarters of that gets a near-limit note.
E0382invalid reflection categoryfield_info takes a struct type and enum_info an enum type. The type must have a field or member to select. Use type_info for scalar, array or view layout.
E0383borrow may outlive its backing storageA returned descriptor or retained store can carry local backing beyond its frame, including through helpers, aggregates and active sum payloads. Return an owned value or use caller-owned backing. The bounded A1/B1 checks retain known local witnesses even with incomplete alternatives; general region lifetimes, B2 local-carrier composition and B3 request ownership remain separate work.
E0384unknown module aliasA qualified name's alias must be bound in this module by #load "FILE.coax" as NAME;. Aliases belong to the logical module that loads them.

E08xx: generic structs

E04xx: compile-time evaluation

E05xx: proto imports

E06xx: source units

E07xx: device code

E08xx: generic structs

E09xx: tagged values and effect declarations