Skip to content

Error Code Reference ​

YaoXiang compiler uses error codes to identify different types of diagnostic information. Error codes are grouped by number range, with each error code corresponding to a specific error scenario.


E0xxx -- Lexical and Syntax Analysis ​

Errors produced during the Lexer and Parser phases.

Error CodeTemplateDescription
E0001Invalid character: '{char}'Invalid character
E0002Invalid number literal: '{literal}'Invalid number literal
E0003Unterminated string starting at line {line}Unterminated string
E0004Invalid character literal: '{literal}'Invalid character literal
E0010Expected {expected}, found {found}Expected token
E0011Unexpected token: '{token}'Unexpected token
E0012Invalid syntax: {reason}Invalid syntax
E0013Mismatched {bracket_type}: opened at line {open_line}, column {open_col}, not closedMismatched bracket
E0014Missing semicolon after {statement}Missing semicolon

E1xxx -- Type Checking ​

Errors produced during the type checking phase, covering variable types, function calls, pattern matching, generic instantiation, concurrency semantics, and error propagation.

Error CodeTemplateDescription
E1001Unknown variable: '{name}'Unknown variable
E1002Expected type '{expected}', found type '{found}'Type mismatch
E1003Unknown type: '{type}'Unknown type
E1010Function '{func}' expects {expected} arguments, found {found}Argument count mismatch
E1011Parameter type mismatch: expected '{expected}', found '{found}'Parameter type mismatch
E1012Return type mismatch: expected '{expected}', found '{found}'Return type mismatch
E1013Function not found: '{func}'Function not found
E1020Cannot infer type for '{expr}'Cannot infer type
E1021Type inference conflict: {reason}Type inference conflict
E1030Pattern non-exhaustive: missing patterns {patterns}Pattern non-exhaustive
E1031Unreachable pattern: '{pattern}'Unreachable pattern
E1040Operation '{op}' is not supported for type '{type}'Operation not supported
E1041Index out of bounds: valid range is 0..{max}, found {index}Index out of bounds
E1042Field '{field}' not found in struct '{struct}'Field not found
E1050Logical operation requires boolean operands, found '{left}' and '{right}'Boolean operand required
E1051Logical NOT requires boolean operand, found '{type}'Logical NOT requires boolean operand
E1052Cannot dereference type '{type}', expected pointer typeInvalid dereference
E1053Cannot access field on non-struct type '{type}'Non-struct field access
E1054Condition must be boolean, found '{type}'Condition type mismatch
E1055Constraint type '{type}' can only be used in generic contextConstraint in non-generic context
E1060Expected {expected} type argument(s), found {found}Type argument count mismatch
E1061Cannot instantiate generic type with given argumentsCannot instantiate generic
E1081`?` is only allowed inside functions returning Result? is only allowed inside functions returning Result
E1082`?` requires a Result expression, found '{type}'? requires a Result expression
E1083Result error type mismatch for `?`: expected '{expected}', found '{found}'? error type mismatch
E1090Type: Type = TypeUnspeakable (Easter egg)
E1091Generic meta-type self-reference is not allowed: '{decl}'Invalid generic meta-type
E1062Const generic constraint violation: {reason}const generic constraint violation
E1064Invalid binding position(s) {positions} for function with {total} parameter(s)Invalid binding position index (RFC-004)
E1095Unknown interface: '{name}'Unknown interface (RFC-011a)
E1096Interface '{name}' expects {expected} type argument(s), found {found}Interface instantiation argument count mismatch
E1097Interface member '{member}' conflicts with field of type '{type}'Interface member conflicts with field name
E1098Type '{type}' does not implement '{interface}.{method}'Interface method not implemented
E1099Signature mismatch for '{type}.{method}': expected '{expected}', found '{found}'Interface method signature mismatch
E1100Duplicate implementation of '{type}.{method}' (override is not allowed)Duplicate method implementation (override forbidden)
E1101Type '{type}' does not implement interface '{interface}' and cannot enter this existential positionType does not implement interface (existential type member check)

E2xxx -- Semantic Analysis ​

Errors produced during the semantic analysis phase, covering scope, variable lifetime, ownership, and function signature resolution.

Error CodeTemplateDescription
E2001Variable '{name}' is not in scopeScope error
E2002Duplicate definition: '{name}' is already defined in this scopeDuplicate definition
E2003Ownership constraint violated: {reason}Ownership error
E2010Cannot assign to immutable variable '{name}'Immutable assignment
E2011Use of uninitialized variable '{name}'Use of uninitialized variable
E2012Mutability conflict: cannot use mutable reference in immutable contextMutability conflict
E2013Cannot shadow existing variable '{name}'Variable shadowing
E2014'{name}' has been moved and cannot be usedUse of moved variable
E2090Invalid signature: {reason}Invalid signature
E2091Invalid signature: unknown type '{type_name}'Signature unknown type
E2092Invalid signature: missing '->'Signature missing arrow
E2093Invalid signature: duplicate parameter '{name}'Duplicate parameter name
E2094Invalid signature: generic '{name}' shadows outer genericGeneric parameter shadowing
E2095Invalid signature: parameter '{name}' shadows genericParameter name shadows generic

E4xxx -- Generics and Traits ​

Errors related to generic constraints and the trait system.

Error CodeTemplateDescription
E4001Type '{type}' does not satisfy the trait bound '{trait}'Generic constraint violation
E4002Trait '{trait}' not foundTrait not found
E4003Missing implementation for trait '{trait}' for type '{type}'Missing trait implementation
E4004Conflicting trait implementations for '{trait}'Conflicting trait implementations
E4005Associated type '{assoc_type}' not found in '{container}'Associated type not found

E5xxx -- Modules and Imports ​

Errors related to the module system and imports.

Error CodeTemplateDescription
E5001Module '{module}' not foundModule not found
E5002Failed to import module '{module}': {reason}Import error
E5003Export '{export}' not found in module '{module}'Export not found
E5004Circular dependency detected: {path}Circular dependency
E5005Invalid module path: '{path}'Invalid module path
E5006Duplicate import: '{name}' is already importedDuplicate import
E5007Module '{module}' exports: {available}Module export hint

E6xxx -- Runtime ​

Errors produced during the runtime phase.

Error CodeTemplateDescription
E6001Division by zero in expression: {expr}Division by zero
E6003Array index out of bounds: valid range is 0..{max}, found {index}Array index out of bounds
E6004Stack overflow: recursion depth exceeded limit {limit}Stack overflow
E6005Assertion failed: {condition}Assertion failed
E6006Function not found: '{func}'Function not found (runtime)
E6007Runtime error: {message}Runtime error

E7xxx -- I/O and System ​

I/O operations and system-level errors.

Error CodeTemplateDescription
E7001File not found: '{path}'File not found
E7002Permission denied: '{path}'Permission denied
E7003I/O error: {reason}I/O error
E7004Network error: {reason}Network error

E8xxx -- Internal Compiler Errors ​

Internal compiler errors, typically indicating a bug in the compiler itself. If you encounter such errors, please report them at GitHub Issues.

Error CodeTemplateDescription
E8001Internal compiler error: {message}Internal compiler error
E8002Unexpected compiler panic: {reason}Unexpected panic
E8003Compiler phase error: {phase} - {message}Compiler phase error

W1xxx -- Warnings ​

Warnings related to dead code detection. Warnings do not prevent compilation but indicate potential issues in the code.

Error CodeTemplateDescription
W1001Unused exported function: '{name}'Unused exported function
W1002Unused exported type: '{name}'Unused exported type
W1003Unused import: '{name}'Unused import
W1004Unused exported variable: '{name}'Unused exported variable
W1005Unused exported method: '{name}'Unused exported method
W1063const generic constraint cannot be evaluated: `{constraint}` ({var} = {value})const generic constraint cannot be evaluated
W1080Constraint cannot be proven at compile-time, degraded to runtime checkCompile-time proof degradation

A total of 118 diagnostic codes (111 error codes + 7 warning codes), with the define_codes! registry (src/util/diagnostic/codes/) as the authoritative source; the complete registration list for each code follows the registry, and this page lists common codes by family.