XIOM Error Codes -- Reference¶
Each XIOM diagnostic carries a code. Codes are stable: once assigned they are never deleted or reassigned. The same pages are published on the documentation site: https://docs.xiom-lang.org/latest/error-codes/
Emitted codes¶
| Code | Stage | Meaning | Doc |
|---|---|---|---|
| L001 | Lexer | Source cannot be tokenized (bad literal, bad escape) | L001 |
| P001 | Parser | Grammar error, messages shaped expected X, found Y |
P001 |
| T001 | Type checker | Type and semantic errors (umbrella code) | T001 |
| E001 | Borrow checker | Ownership / borrow rule violation | E001 |
| C001 | Codegen | Internal code generation failure | C001 |
| W000 | Checker | Non-fatal checker warning | W000 |
| W001 | Catalog | Module name collision | W001 |
Codes appear in CLI output as error[CODE]: line:col: message and in
--diagnostics=json output as the code field of each diagnostic.
Reserved codes (not emitted)¶
The X family below was reserved in an early design and is not emitted by the
current compiler. The numbers stay reserved so they can never be reused.
The pages are kept for continuity: X0010 type mismatch,
X0011 undefined variable, X0100 contract requires
violation. Those situations are reported as T001 today, and a runtime
contract trap prints Contract violation: requires: ... without a code.
Writing a new error code¶
- Create
docs/error_codes/{CODE}.mdin the website repository - Include: short description, an example, fix, notes
- Add the row and link to the emitted table above
- Codes are never deleted -- mark deprecated codes as such
Using --explain¶
xiom --explain T001
# Prints docs/error_codes/T001.md when that directory is present in the
# current working directory, then a pointer to this index.
--explain resolves the file relative to the current directory, so it works
inside a checkout that carries docs/error_codes/. Installed toolchains do
not ship the reference yet; use the published pages above in that case.