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:
$ 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:
| Prefix | Stage | Where to read more |
|---|---|---|
E01 | Lexer | Chapter 4 |
E02 | Parser | Chapter 4 |
E03 | Checker | Chapter 4 |
E04 | Compile-time evaluation and checks | Chapters 9 and 11 |
E05 | Protobuf descriptor imports | Chapter 18 |
E06 | Source-unit composition | Chapter 10 |
E07 | Device code (coax cuda, coax metal-compute, coax spirv) | Chapter 17 |
E08 | Generic structs | Chapter 8 |
E09 | Tagged values and effect declarations | Chapters 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
| Code | Meaning | What to do |
|---|---|---|
E0101 | block comment is never closed | A /* comment has no matching / before the end of the file. Block comments nest, so every / inside needs its own */. |
E0102 | retired in 0.3.0 | Was: floating-point literals are not supported. Floats arrived in 0.3.0. |
E0103 | number has no digits after its base prefix | 0x and 0b must be followed by at least one digit of that base. |
E0104 | integer literal does not fit in 64 bits | Integer literals go up to 18446744073709551615 (the u64 maximum). Where the literal is used, it must also fit that type. |
E0105 | unknown escape in a string | Strings support \n \t \r \0 \ and ". Unicode and hex escapes are planned. |
E0106 | string is never closed | A string ends with a " on the same line. Strings cannot span lines yet. |
E0107 | non-ASCII character outside a string or comment | Identifiers and operators are ASCII. UTF-8 text belongs in strings and comments. |
E0108 | unexpected character | The character starts no token in Coax. |
E0109 | bad floating-point literal | The 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. |
E0110 | invalid character literal | A 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. |
E0111 | lexer source or storage limit | Source must fit signed 32-bit byte offsets and one-based EOF locations. Native lexer buffers must meet the Coax capacity contract. |
E02xx: parser
| Code | Meaning | What to do |
|---|---|---|
E0201 | expected a token | The parser needed a specific token here, usually ';', ')' or '}'. For a missing ';' the caret points right after the previous token. |
E0202 | expected a type | A 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. |
E0203 | comparisons cannot be chained | a < b < c is rejected rather than given a surprising meaning. Write a < b && b < c. |
E0204 | reserved word not supported yet | The word is reserved for a planned feature, such as using or enum_flags. coax0 refuses it rather than guessing what it means. |
E0205 | expected an expression | A value was needed here: a literal, a name, a call, or a parenthesized expression. |
E0206 | local declarations with :: are not supported | Constants, procedures and types are declared at the top level in coax0. |
E0207 | cannot assign to this expression | Only a variable, a struct field or an element (a[i]) can be assigned. |
E0208 | expected a name | A parameter, field, member or loop variable name was expected here. |
E0209 | expected a module name after #import | Write #import "Basic"; |
E0210 | directive not supported here | The 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. |
E0211 | retired in 0.2.0 | Was: only procedures can be declared at the top level. Top-level constants arrived in 0.2.0. |
E0212 | global variables are not supported | Top-level mutable state is not part of coax0. Use constants, or pass state explicitly. |
E0213 | expected a top-level declaration | The top level holds #import, #assert and declarations 'name :: ...'. |
E0214 | unknown cast modifier | The only modifier is trunc: cast,trunc(u8) x keeps the low bits instead of checking that the value fits. |
E0215 | struct literal needs a struct name | Write the struct's name before .{ }: Point.{x = 1, y = 2}. Inferred literals are planned. |
E0216 | ranges are half-open | Coax ranges are written lo..<hi and include lo but not hi. '..' alone is not a range. |
E0217 | array literal needs a fixed array type | Write the type first: [3] int.[1, 2, 3]. |
E0218 | a range loop has one variable | for i: 0..<n { } has a counter only. Index variables belong to loops over arrays, views and strings. |
E0219 | enum needs an underlying type | An enum names its integer width: Outcome :: enum u8 { ... }. The width is part of its layout. |
E0220 | malformed 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 { ... }. |
E0221 | parser resource limit | The 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. |
E0223 | malformed struct parameter list | A 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; }. |
E0222 | qualified name reaches through an alias | A 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. |
E0224 | malformed #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. |
E0225 | a spelling from another language | The 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
| Code | Meaning | What to do |
|---|---|---|
E0301 | type not supported yet | The type is in the plan (spec 6.2) but coax0 does not implement it, for example dynamic arrays '[..] T' or vectors. |
E0302 | unknown type | No built-in type, struct or enum has this name. |
E0303 | 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. |
E0304 | retired in 0.52.0 | Was: 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. |
E0305 | procedures are not values | Procedure 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; }. |
E0306 | name is not declared | No local, parameter or constant with this name is in scope here. |
E0307 | '-' needs a signed integer or a float | Unsigned integers have no negation. Subtract from a value, or use a signed type. |
E0308 | '!' needs a bool | There is no truthiness. Compare instead: x == 0. |
E0309 | arithmetic 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. |
E0310 | ordering needs two numbers of one type | < <= > >= compare two integers or two floats of the same type. |
E0311 | cannot 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. |
E0312 | boolean operator needs two bools | && and || take bools and short-circuit. |
E0313 | retired in 0.52.0 | Was: print needs Basic. Basic is imported by default, so print needs no #import; #import "Basic"; is still accepted. |
E0314 | not a procedure | A constant or variable was called like a procedure. |
E0315 | procedure is not declared | No procedure has this name. Procedures may be declared after they are used. |
E0316 | wrong number of arguments | The call passes a different number of arguments than the procedure declares. |
E0317 | argument has the wrong type | Each argument must have its parameter's type exactly. An array is passed as a view with name[..]. |
E0318 | print needs a format string | print("text\n"); the format comes first. |
E0319 | print's format must be a literal | The format is checked while compiling, so it must be a string literal. |
E0320 | format slots and values differ | Each % in the format takes one value. Write %% for a percent sign. |
E0321 | cannot print nothing | This call returns no value, so there is nothing to print. |
E0322 | value is not used | An expression statement must do something: call a procedure, or assign its value. To evaluate an expression and drop its value on purpose, write _ = expression;. |
E0323 | result is not used | The 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. |
E0324 | cannot initialize from nothing | The call returns no value, so it cannot initialize a variable. |
E0325 | initializer has the wrong type | The variable's declared type and its initializer differ. There are no implicit conversions. |
E0326 | compound assignment needs a number | += -= *= /= need a number target; %= &= |= ^= <<= >>= need an integer. |
E0327 | assigned value has the wrong type | The value's type differs from the target's. |
E0328 | missing return value | The procedure declares a result, so return needs a value. |
E0329 | procedure returns nothing | A value is returned from a procedure without '-> T'. |
E0330 | returned value has the wrong type | The value differs from the declared result type. |
E0331 | condition must be bool | if, while and ifx take a bool. Compare explicitly: x != 0. |
E0332 | module imported twice | Remove the second #import. |
E0333 | unknown module | coax0 has one module, Basic. |
E0334 | procedure declared twice | There are no overloads yet; every procedure name is unique. |
E0335 | name is a builtin | print (with Basic) and type_name are reserved by the compiler. |
E0336 | no main | coax 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. |
E0337 | main has the wrong signature | main takes no parameters and returns nothing in coax0. |
E0338 | missing return | Some path reaches the end of a procedure that must return a value. |
E0339 | too many generic instances | A 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. |
E0340 | constant dependency cycle | Constants may refer to each other in any order, but not in a circle. |
E0341 | constant has no value | A constant or #run must produce a value; a call returning nothing cannot. |
E0342 | name is a constant, type or intrinsic | A local cannot take the name of a constant, struct, enum or intrinsic. |
E0343 | type_name needs one value | type_name(x) takes exactly one expression with a value. It is checked but never run. |
E0344 | cannot assign a constant or parameter | Constants never change. Parameters are immutable: copy one into a local to update it. |
E0345 | duplicate or conflicting constant | The constant's name is already a constant, procedure or intrinsic. |
E0346 | #assert needs bool | The asserted expression must be a bool, at the top level and in a statement. |
E0347 | constant dependencies too deep | Constant type resolution is bounded at depth 64. |
E0348 | type parameter bound twice | The 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. |
E0349 | argument does not have the parameter's shape | A 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. |
E0350 | value does not fit its type | Untyped 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. |
E0351 | no such field or member | The struct has no field, or the enum no member, with this name. Arrays, views and strings have .count. |
E0352 | duplicate field or member | A field or member name appears twice in a declaration or a literal. |
E0353 | struct contains itself | A struct cannot hold itself by value; its size would be infinite. Hold it through a view, or by index. |
E0354 | a type is not a value | A struct or enum name was used as a value. Make a struct with Name.{ }, or name an enum member with Name.member. |
E0355 | cannot index or slice this | Only arrays, views and strings can be indexed and sliced. |
E0356 | index must be an integer | Indices and slice bounds are integers of any width. They are checked against the length at run time. |
E0357 | array length not known while checking | An 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. |
E0358 | array literal has the wrong count | [N] T.[...] gives exactly N elements. |
E0359 | cannot assign this | The target is a loop variable, a string byte, .count, or a temporary. Strings are immutable; copy the bytes into [N] u8 to change them. |
E0360 | break or continue outside a loop | break and continue belong inside while and for. |
E0361 | deferred code cannot leave its block | A deferred statement runs while its block exits, so it cannot return, break or continue out of it. |
E0362 | invalid cast | cast converts between numbers, and between enums and integers. cast,trunc converts between integer types only. |
E0363 | invalid enum value | Enum values are integers known while checking, fit the underlying type, and are distinct. |
E0364 | cannot loop over this | for takes a half-open range lo..<hi of one integer type, an array, a view, or a string. |
E0365 | ifx branches differ | Both branches of ifx produce a value of the same type. |
E0366 | a view needs a variable array | A 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. |
E0367 | field or element has the wrong type | The value given for a struct field, field default or array element has a different type. |
E0368 | type and value parameters share a name | A $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. |
E0369 | invalid export | main cannot be exported, and exported names cannot start with coax_, which the generated runtime uses. |
E0370 | bit operation needs integers | & | ^ need two integers of one type; << >> shift an integer by an integer amount from 0 to its width minus one. |
E0371 | field name is reserved in C | Struct fields keep their names in generated C and headers, so they cannot be C or C++ keywords or start with '_'. |
E0372 | type name conflicts | A struct or enum name is already used by another type, a procedure, a constant, or a built-in. |
E0373 | enum base must be an integer | An enum's underlying type is one of s8..s64 or u8..u64. |
E0374 | constant index out of bounds | An index written as a constant must be inside a fixed array's length. Indexes computed at run time are checked when they run. |
E0375 | math or string intrinsic misused | sin 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). |
E0376 | procedure cannot cross the C boundary | A #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_. |
E0377 | outside the Metal scalar profile | coax 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. |
E0378 | byte intrinsic argument mismatch | bytes_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 enumerated | A #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. |
E0380 | procedure not exercised by a check | Every 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. |
E0381 | type checker resource limit | The 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. |
E0382 | invalid reflection category | field_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. |
E0383 | borrow may outlive its backing storage | A 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. |
E0384 | unknown module alias | A 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. |