Adding Error Codes
Overview
Vole uses structured error codes: E0xxx (lexer), E1xxx (parser), E2xxx (semantic).
Checklist
Get next available code:
just dev next-error sema # For semantic errors (E2xxx) just dev next-error parser # For parser errors (E1xxx) just dev next-error lexer # For lexer errors (E0xxx)List existing errors (for reference):
just dev list-errors sema just dev list-errors parser just dev list-errors all # All categoriesAdd error variant to the appropriate file:
Error Type File Lexer src/crates/vole-frontend/src/errors/lexer.rsParser src/crates/vole-frontend/src/errors/parser.rsSemantic src/crates/vole-sema/src/errors/mod.rsEmit the error in the relevant analyzer/parser code:
Error Type Emission Location Lexer src/crates/vole-frontend/src/lexer.rsParser src/crates/vole-frontend/src/parser/*.rsSemantic src/crates/vole-sema/src/analyzer/**/*.rsSema errors use
self.add_error(SemanticError::Variant { span }, span).Add snapshot test for error message:
- Create
test/snapshot/check/sema/your_error.volewith code that triggers the error - Run
cargo run -p vole-snap -- bless test/snapshot/check/sema/your_error.vole
- Create
Verify:
just pre-commit
Converted and distributed by TomeVault — claim your Tome and manage your conversions.