Diagnostics and error codes
The stable error-code catalogue, and how to look any code up.
Every diagnostic may carry a stable code. The code is assigned where the
compiler detects the problem, never guessed from rendered text afterwards, so
the code and the message always describe the same fact. A diagnostic with no
code renders as (uncoded) rather than a wrong code, when a new construct is
added, its diagnostic stays uncoded until a code exists that says exactly what
happened.
Codes are grouped by area:
| Range | Area |
|---|---|
E01xx |
Lexing and parsing |
E02xx |
Declarations, name resolution, inheritance |
E03xx |
Type checking and expressions |
E04xx |
Operations, attributes, calls, memory builtins |
E05xx |
Ownership and memory |
E07xx |
Stored or returned references |
Looking up a code
pickle-cli explain # every code in the catalogue
pickle-cli explain E0343 # one code, with a worked example
pickle explain prints the rule and an example with no documentation to
install, which makes it usable from a CI log.
The catalogue
E01xx: lexical and syntax
| Code | Meaning |
|---|---|
E0101 |
Lexical error, a byte sequence that is not a token, an unterminated literal |
E0111 |
Syntax error, the token stream does not form a valid declaration, statement or expression |
E02xx: declarations and name resolution
| Code | Meaning |
|---|---|
E0201 |
Duplicate declaration |
E0202 |
Duplicate import alias |
E0203 |
Duplicate member |
E0204 |
Duplicate constructor |
E0205 |
Duplicate deinit |
E0206 |
Module not found |
E0207 |
Item not exported by module |
E0208 |
Module path mismatch |
E0209 |
Ambiguous imported name |
E0210 |
Unknown type |
E0211 |
Type is not generic |
E0212 |
Wrong number of type arguments |
E0213 |
List of references |
E0220 |
Invalid extends |
E0221 |
Override signature mismatch |
E0222 |
Missing override |
E0223 |
Orphan override |
E0224 |
Mixed method kind |
E03xx: type checking and expressions
| Code | Meaning |
|---|---|
E0308 |
Type mismatch |
E0310 |
Return value error |
E0320 |
break or continue outside a loop |
E0340 |
Condition is not bool |
E0341 |
for-in requires a sequence |
E0342 |
Map keys must be a supported type |
E0343 |
Index error |
E0351 |
Undeclared name |
E0352 |
No such member |
E0353 |
Enum variant error |
E0354 |
Cannot construct this type |
E0355 |
Member assignment on a non-class value |
E0360 |
Interface conformance |
E0361 |
this / super misuse |
E0362 |
Invalid assignment |
E0363 |
Invalid cast or is |
E04xx: operations, attributes, calls and memory builtins
| Code | Meaning |
|---|---|
E0400 |
Attribute error |
E0401 |
manualAlloc misuse |
E0410 |
Call argument error |
E0411 |
Call of a non-function |
E0420 |
Member access on a non-class value |
E0430 |
Operator operand error |
E0440 |
alloc / free misuse |
E05xx: ownership and memory
| Code | Meaning |
|---|---|
E0501 |
Use after free() or after a move |
E0502 |
Already freed |
E0503 |
free on a non-manual value |
E0504 |
Owned position |
E0505 |
Overwrite, or non-owning return, of a manual value |
E0506 |
Leaked owned result |
E0520 |
unsafe required |
E07xx
| Code | Meaning |
|---|---|
E0700 |
Stored or returned reference |
A few you will actually hit
E0362 invalid assignment has two common causes that look identical in the
message. Assigning to a let gives cannot assign to immutable binding, but
assigning to something that is not a variable, member or index gives
assignment target must be a variable, member, or index, which is what you
get from *p = 1 on a value that is not a pointer.
E0420 member access on non-class value is how the absence of string methods
surfaces:
error[E0420] -- member access on non-class value
error: cannot access member `len` on value of type `string`
E0520 unsafe required names the block that has to wrap the code, and the
message tells you which construct triggered it.
