Skip to content

Error Code Reference ​

This page is generated by scripts/docs/gen-error-code-docs.py from the define_codes! registry in src/util/diagnostic/codes/ and locales/en.json. Do not edit it by hand. Change the wording in locales/*.json, change the code table in define_codes!, then rerun python scripts/docs/gen-error-code-docs.py.

Every YaoXiang diagnostic carries a stable code (such as E1001) for lookup, for citation in issues, and for filtering by code in CI. The user-visible wording of a diagnostic (title / template / help) comes from locales/*.json; yx explain <code> prints it in the terminal.

Code Numbering ​

A code consists of a prefix (the family) and a four-digit sequence; the family names the compiler phase.

Family prefixCategoryMeaningRegistered codes
E0xxxLexer / ParserLexical and syntax analysis errors12
E1xxxTypeCheckType-checking errors62
E2xxxSemanticSemantic analysis errors23
E3xxxCodegenCode generation errors (including IR consistency checks)14
E4xxxGenericGeneric, trait, and constant evaluation errors15
E5xxxModuleModule and import errors8
E6xxxRuntimeRuntime errors (VM and std native functions)7
E7xxxIoI/O and system errors4
E8xxxInternalInternal compiler errors (defects in the compiler itself)3
W1xxxWarningWarnings (the W family emits at the warn level by default and does not block compilation; the exception is W1090, which emits at the error level and blocks compilation)12

The E3xxx family was not listed in any documentation before; it is now part of this page. Its codes are produced during IR generation and entry-point checks.

Statistics ​

  • The define_codes! registry holds 160 entries (148 E codes and 12 W codes).
  • std-layer runtime codes: 5 (not in the define_codes! registry; see the next section).
  • 165 diagnostic codes in total.
  • 32 of the registered codes have no emission site in non-test code and are marked "Not yet emitted"; their code numbers are retained, but users cannot trigger them yet.

Quick Reference by Code Prefix ​

Family prefixCategoryMeaningDetails
E0xxxLexer / ParserLexical and syntax analysis errorsFamily page: E0xxx
E1xxxTypeCheckType-checking errorsFamily page: E1xxx
E2xxxSemanticSemantic analysis errorsFamily page: E2xxx
E4xxxGenericGeneric and trait errorsFamily page: E4xxx
E5xxxModuleModule and import errorsFamily page: E5xxx
E6xxxRuntimeRuntime errorsFamily page: E6xxx
E7xxxIoI/O and system errorsFamily page: E7xxx
E8xxxInternalInternal compiler errorsFamily page: E8xxx
W1xxxWarningWarningsW1xxx

The E3xxx family has no page of its own; all of its codes are listed in the full inventory below.

Full Code Inventory ​

The "Template" column comes from locales/en.json and shows the diagnostic body with its parameters substituted; "Emission sites" counts the call sites of the code in non-test code.

CodeNameCategoryspan exemptTemplateEmission sites
E0001Invalid characterLexerNoInvalid character: '{char}'✅ 1 site
E0002Invalid number literalLexerNoInvalid number literal: '{literal}'✅ 1 site
E0003Unterminated stringLexerNostring started at line {line} is unterminated⚠ Not yet emitted
E0004Invalid character literalLexerNoinvalid character literal: '{literal}'⚠ Not yet emitted
E0010Expected tokenParserNoexpected {expected}, found {found}✅ 6 sites
E0011Unexpected tokenParserNoUnexpected token: '{token}'✅ 19 sites
E0012Invalid syntaxParserNoInvalid syntax: {reason}✅ 14 sites
E0013Mismatched bracketsParserNoMismatched {bracket_type}: opened at line {open_line}, column {open_col}, not closed⚠ Not yet emitted
E0014Missing semicolonParserNoMissing semicolon after {statement}⚠ Not yet emitted
E0016Expected expressionParserNoExpected expression: {context}✅ 4 sites
E0018Keyword used as nameParserNo'{keyword}' is a keyword and cannot be used as a name✅ 1 site
E0019Expression nesting too deepParserNoexpression nesting exceeds the maximum recursion depth ({limit})✅ 1 site
E1001Unknown variableTypeCheckNoUnknown variable: '{name}'✅ 6 sites
E1002Type mismatchTypeCheckNoExpected type '{expected}', found type '{found}'✅ 77 sites
E1003Unknown typeTypeCheckNoUnknown type: '{type}'✅ 3 sites
E1010Argument count mismatchTypeCheckNofunction '{func}' expected {expected} arguments, found {found}✅ 19 sites
E1011Implementation parameter annotation mismatchTypeCheckNoimplementation parameter annotation mismatch: expected '{expected}', found '{found}'✅ 1 site
E1012Return type mismatchTypeCheckNoreturn type mismatch: expected '{expected}', found '{found}'✅ 4 sites
E1013Function not foundTypeCheckNoFunction not found: '{func}'✅ 3 sites
E1014Unknown named argumentTypeCheckNoFunction '{func}' has no parameter named '{name}' (available: {params})✅ 2 sites
E1015Argument specified more than onceTypeCheckNoParameter '{name}' of function '{func}' was specified more than once✅ 1 site
E1020Cannot infer typeTypeCheckNoCannot infer the type of '{expr}'⚠ Not yet emitted
E1021Type inference conflictTypeCheckNotype inference conflict: {reason}⚠ Not yet emitted
E1030Non-exhaustive patternsTypeCheckNonon-exhaustive patterns: missing {patterns}✅ 2 sites
E1031Unreachable patternTypeCheckNounreachable pattern: '{pattern}'✅ 5 sites
E1032Duplicate binding in patternTypeCheckNoDuplicate pattern binding: '{name}' appears multiple times in the same pattern✅ 2 sites
E1033Inconsistent bindings in or-patternTypeCheckNoInconsistent bindings in or-pattern: both sides of \|` must bind the same set of names`✅ 1 site
E1034Missing field in struct patternTypeCheckNoStruct pattern missing field '{field}' (all fields of '{struct}' must be fully covered)✅ 1 site
E1040Operation not supportedTypeCheckNotype '{type}' does not support operation '{op}'⚠ Not yet emitted
E1041Index out of boundsTypeCheckNoindex out of bounds: valid range is 0..{max}, found {index}✅ 5 sites
E1042Field not foundTypeCheckNofield '{field}' not found in struct '{struct}'✅ 10 sites
E1043Module member not foundTypeCheckNoModule '{module}' did not export '{name}'✅ 1 site
E1050Boolean operand requiredTypeCheckNoLogical operation requires boolean operands, got '{left}' and '{right}'✅ 1 site
E1051Logical NOT requires boolean operandTypeCheckNoLogical NOT requires boolean operand, got '{type}'✅ 1 site
E1052Invalid dereferenceTypeCheckNoCannot dereference type '{type}', expected pointer type✅ 1 site
E1053Non-struct field accessTypeCheckNoCannot access field on non-struct type '{type}'✅ 2 sites
E1054Condition type mismatchTypeCheckNoCondition must be a boolean type, got '{type}'✅ 4 sites
E1055Constraint in non-generic contextTypeCheckNoConstraint type '{type}' can only be used in a generic context⚠ Not yet emitted
E1060Type parameter count mismatchTypeCheckNoexpected {expected} type parameters, found {found}⚠ Not yet emitted
E1061Cannot instantiate genericTypeCheckNocannot instantiate generic type with given parameters⚠ Not yet emitted
E1062Const generic constraint failedTypeCheckNoconst generic constraint failed: \` does not hold`✅ 1 site
E1064Invalid binding position indexTypeCheckNoInvalid binding position index: {positions} (the function has {total} parameters)✅ 3 sites
E1065Call of non-function valueTypeCheckNotype \` is not callable — it is not a function`✅ 1 site
E1071Type definitions only allowed at module levelTypeCheckNotype definition '{name}' is only allowed at module level (module top level)✅ 2 sites
E1081? is only allowed in functions returning a propagatable typeTypeCheckNo\?` is only allowed in functions returning a type that implements `Try``✅ 2 sites
E1082? can only be used on types that implement TryTypeCheckNo'{type}' does not implement the \Try` interface, so `?` cannot be used`✅ 1 site
E1083Error type mismatch for ?TypeCheckNoError type mismatch for \?`: expected '{expected}', found '{found}'`✅ 1 site
E1090✨ Unspeakable ✨TypeCheckNoType: Type = Type⚠ Not yet emitted
E1091Invalid generic meta typeTypeCheckNoGeneric meta type self-reference is not allowed: '{decl}'✅ 1 site
E1092Invalid refinement type argument formTypeCheckNo'{name}' requires a compile-time constant argument, but the given argument cannot be converted✅ 10 sites
E1093Refinement argument count mismatchTypeCheckNo'{name}' expected {expected} argument(s), found {found}✅ 2 sites
E1094Unused compile-time value parameterTypeCheckNo'{param}' is declared as a compile-time value parameter of '{type}', but is not referenced in the type body✅ 1 site
E1095Unknown interfaceTypeCheckNoUnknown interface: '{name}' (the name referenced by the type body is not a registered type constructor)✅ 1 site
E1096Interface parameter count mismatchTypeCheckNoInterface '{name}' expected {expected} type parameters, found {found}✅ 3 sites
E1097Interface member naming conflictTypeCheckNoMember '{member}' of type '{type}' conflicts with an interface member (fields and methods share a namespace, §1.2)✅ 1 site
E1098Interface method not implementedTypeCheckNotype '{type}' does not implement method '{method}' of interface '{interface}'✅ 1 site
E1099Interface method signature mismatchTypeCheckNomethod '{method}' of type '{type}' does not match the interface signature: expected {expected}, found {found}✅ 2 sites
E1100Duplicate interface method implementationTypeCheckNomethod '{method}' of type '{type}' is implemented more than once (same-signature override is forbidden, §3)✅ 1 site
E1101Type does not implement interfaceTypeCheckNotype '{type}' does not implement interface '{interface}' and cannot enter this existential type position✅ 5 sites
E1102Loop control statement appears outside a loopTypeCheckNo'{keyword}' appears outside a loop✅ 2 sites
E1103Square brackets cannot be used in type positionTypeCheckYes'{name}[...]' is not type syntax—type arguments require parentheses✅ 1 site
E1104Interface implementation is not in the type's defining moduleTypeCheckNoType '{type}' is not defined by this module; interface '{interface}' cannot be implemented for it in this module✅ 1 site
E1105Variant constructor cannot be used as field accessTypeCheckNo'{variant}' is a variant constructor of the sum type '{type}', not a data field✅ 1 site
E1106Constrained method dispatch failedTypeCheckNoConstrained method dispatch failed: \`—{detail}`✅ 1 site
E1107Method overload ambiguityTypeCheckNoMethod overload ambiguity: '{key}' has {count} candidate matches that cannot be distinguished✅ 1 site
E1108Empty block in container expected positionTypeCheckYesA container type is expected here, but \{}` is an empty block (value Void)`✅ 2 sites
E1109Return appears outside a functionTypeCheckNo'return' appears outside a function✅ 3 sites
E1110Method binding missing signature annotationTypeCheckNo'{type}.{method}' is missing a signature annotation✅ 1 site
E1111Argument duplicate or invalid orderTypeCheckNofunction '{func}' parameter '{name}' received multiple arguments (or argument order is invalid)✅ 2 sites
E1112Implementation declares more parameters than the signatureTypeCheckNoThe annotation for function '{name}' provides only {expected} runtime parameter slots, but the implementation header specifies {found} parameters; the extra one has no value to bind to.✅ 1 site
E1113Compile-time value parameter lacks compile-time evidenceTypeCheckNoCompile-time value parameter '{param}' requires compile-time evidence, but the argument cannot be determined at compile time✅ 1 site
E1114Witness field is not readable at value levelTypeCheckNoWitness field '{field}' is compile-time evidence of record '{type}' and has no runtime data slot; it cannot be read at value level✅ 3 sites
E1115Witness-bearing record is immutableTypeCheckNoRecord '{type}' carries a witness field, so all of its fields must stay unchanged after construction✅ 4 sites
E1116Bare name collides with exports of multiple standard library unitsTypeCheckNo'{name}' is exported by multiple standard library units ({units}); a bare name cannot determine the call target✅ 1 site
E2001Scope errorSemanticNoVariable '{name}' is not in scope⚠ Not yet emitted
E2002Duplicate definitionSemanticNoredefinition: '{name}' is already defined in the current scope✅ 4 sites
E2003Ownership errorSemanticNoownership constraint violated: {reason}✅ 1 site
E2010Immutable assignmentSemanticNocannot assign to immutable variable '{name}'✅ 2 sites
E2011Use of uninitialized variableSemanticNouse of uninitialized variable '{name}'⚠ Not yet emitted
E2012Mutability ConflictSemanticNoMutability conflict: cannot use mutable reference in immutable context⚠ Not yet emitted
E2013Variable ShadowingSemanticNoCannot shadow existing variable '{name}'✅ 3 sites
E2014Use of moved valueSemanticNo'{name}' has been moved and cannot be used again✅ 1 site
E2016Immutable assignmentSemanticNoCannot assign to immutable variable '{name}'✅ 1 site
E2018Mutable/immutable borrow conflictSemanticNoCannot mutable borrow '{name}' (already immutably borrowed)✅ 1 site
E2019Double freeSemanticNoValue '{name}' was freed twice✅ 1 site
E2020Use after freeSemanticNo'{name}' is used after being freed✅ 1 site
E2027Unsafe dereferenceSemanticNoCannot dereference a raw pointer outside of an unsafe block✅ 1 site
E2090Invalid SignatureSemanticNoInvalid signature: {reason}✅ 3 sites
E2091Unknown Type in SignatureSemanticNoInvalid signature: unknown type '{type_name}'⚠ Not yet emitted
E2092Signature Missing ArrowSemanticNoInvalid signature: missing '->'✅ 1 site
E2093Duplicate Parameter NameSemanticNoInvalid signature: duplicate parameter name '{name}'✅ 2 sites
E2094Generic Parameter ShadowingSemanticNoInvalid signature: generic parameter '{name}' shadows an outer generic parameter⚠ Not yet emitted
E2095Parameter name shadows generic parameterSemanticNoInvalid signature: parameter name '{name}' shadows a generic parameter✅ 1 site
E2096Bare container type in signatureSemanticNoInvalid signature: container type '{name}' is missing type arguments✅ 1 site
E2029Reference cycle in spawnSemanticNoReference cycle in spawn: {cycle}✅ 1 site
E2030Refinement type constraint violationSemanticNoAfter assigning to '{assigned}', '{var}' no longer satisfies the refinement type constraint: {constraint} (counterexample: {counterexample})✅ 1 site
E2031Refinement constraint cannot be provenSemanticNoAfter assigning to '{assigned}', the refinement type constraint on '{var}': {constraint} cannot be statically proven within the proof kernel✅ 3 sites
E3004Unsupported iteratorCodegenNoUnsupported iterator type: {iter_type}✅ 2 sites
E3005IR generation errorCodegenNoIR generation error: {message}✅ 25 sites
E3006Unresolved variableCodegenNoIR generation internal error: variable '{name}' could not be resolved✅ 1 site
E3007Top-level binding initialization must be a constantCodegenNoThe initialization of top-level binding '{name}' must be a compile-time constant expression⚠ Not yet emitted
E3008Unsupported match patternCodegenNomatch pattern '{pattern}' is not yet implemented: currently only literal and wildcard (_) patterns are supported✅ 3 sites
E3018Monomorphization instantiation failedCodegenNoGeneric '{func}' instantiation failed: {reason}✅ 3 sites
E3014Register overflowCodegenYesRegister overflow: {id} exceeds limit {limit}✅ 4 sites
E3017Invalid operand (code generation)CodegenNoCode generation: invalid operand: {reason}✅ 4 sites
E3019Top-level binding cyclic dependencyCodegenNoTop-level binding initialization forms a cyclic dependency: {cycle}✅ 1 site
E3020Missing program entryCodegenNoExecutable is missing the main binding ({path})✅ 2 sites
E3021Entry is not a functionCodegenNoProgram entry '{name}' must be a function, but it is a value binding⚠ Not yet emitted
E3022Entry main signature mismatchCodegenNoEntry '{name}' signature mismatch: the runtime calls it with zero arguments, but it requires '{expected}', found '{found}'✅ 1 site
E3023Top-level executable statements are not allowedCodegenYesTop-level executable statements are not allowed under the Bin role (yaoxiang.toml exists)—the program body is main✅ 1 site
E3024Project config is unreadableCodegenYesProject config {path} is unreadable: {detail}✅ 1 site
E4001Generic constraint violationGenericNotype '{type}' does not satisfy trait constraint '{trait}'✅ 1 site
E4002Trait not foundGenericNotrait '{trait}' not found⚠ Not yet emitted
E4003Trait implementation missingGenericNotype '{type}' is missing implementation for trait '{trait}'⚠ Not yet emitted
E4004Conflicting trait implementationsGenericNoConflicting implementations for trait '{trait}'⚠ Not yet emitted
E4005Associated type not foundGenericNoAssociated type '{assoc_type}' not found in '{container}'⚠ Not yet emitted
E4010Constant division by zeroGenericNoDivision by zero in constant expression✅ 3 sites
E4011Constant overflowGenericNoConstant expression overflow✅ 5 sites
E4012Constant recursion too deepGenericNoConstant evaluation exceeds the maximum recursion depth {limit}✅ 1 site
E4014Constant evaluation failedGenericYesUnable to evaluate constant expression: {reason}✅ 11 sites
E4018Refinement predicate violationGenericYesRefinement predicate violated: {constraint}{counterexample}✅ 6 sites
E4019Type equality does not holdGenericNoType equality does not hold: expected {expected}, found {found}✅ 1 site
E4020Proof function requiredGenericNoA proof function is required to verify the constraint✅ 2 sites
E4021Loop termination cannot be automatically provenGenericNoLoop termination cannot be automatically proven: no valid decreasing metric was found✅ 1 site
E4022Measure does not holdGenericNoMeasure does not hold: this call site cannot prove that the measure strictly decreases Counterexample: {counterexample}✅ 1 site
E4023Cannot be proven within the kernelGenericNoCannot prove: {proposition} ({reason})✅ 1 site
E5001Module not foundModuleNoModule '{module}' not found✅ 1 site
E5002Import errorModuleNoFailed to import module '{module}': {reason}✅ 1 site
E5003Export not foundModuleNoexport '{export}' not found in module '{module}'✅ 1 site
E5004Circular dependencyModuleNocircular dependency detected: {path}⚠ Not yet emitted
E5005Invalid module pathModuleNoInvalid module path: '{path}'⚠ Not yet emitted
E5006Duplicate importModuleNoDuplicate import: '{name}' has already been imported✅ 1 site
E5007Module exportsModuleNoExports of module '{module}': {available}⚠ Not yet emitted
E5008Import name conflictModuleNoImport name '{name}' conflicts with an existing binding (imported from '{module}')✅ 1 site
E6001Division by zeroRuntimeYesexpression {expr} divides by zero✅ 5 sites
E6003Array index out of boundsRuntimeYesarray index out of bounds: valid range is 0..{max}, found {index}✅ 3 sites
E6004Stack overflowRuntimeYesstack overflow: recursion depth exceeded limit {limit}✅ 3 sites
E6005Assertion failedRuntimeYesassertion failed: {condition}✅ 3 sites
E6006Function not found (runtime)RuntimeYesFunction not found: '{func}'✅ 1 site
E6007Runtime errorRuntimeYesRuntime error: {message}✅ 3 sites
E6008Key not foundRuntimeYeskey not found: {key}✅ 2 sites
E7001File not foundIoNofile not found: '{path}'⚠ Not yet emitted
E7002Permission deniedIoNopermission denied: '{path}'⚠ Not yet emitted
E7003I/O errorIoNoI/O error: {reason}⚠ Not yet emitted
E7004Network errorIoNoNetwork error: {reason}⚠ Not yet emitted
E8001Internal compiler errorInternalYesInternal compiler error: {message}✅ 16 sites
E8002Unexpected PanicInternalNoUnexpected compiler panic: {reason}⚠ Not yet emitted
E8003Compiler phase errorInternalNoCompiler phase error: {phase} - {message}⚠ Not yet emitted
W1001Unused private functionWarningNounused function: '{name}'✅ 1 site
W1002Unused private typeWarningNounused type: '{name}'✅ 1 site
W1003Unused importWarningNounused import: '{name}'✅ 1 site
W1004Unused private variableWarningNounused variable: '{name}'✅ 1 site
W1005Unused private methodWarningNoUnused method: '{name}'✅ 1 site
W1006Local module shadows dependency packageWarningNolocal module '{module}' shadows dependency package '{dependency}'✅ 2 sites
W1007Module import cycleWarningNoModule import cycle {cycle}: initialization order within the cycle cannot be determined; the order within the cycle follows a deterministic convention based only on lexicographic path order (not a semantic guarantee)✅ 1 site
W1063Const generic constraint cannot be evaluatedWarningNoconst generic constraint cannot be evaluated: \``✅ 1 site
W1081Termination obligation undecidedWarningNo{count} termination measure obligation(s) undecided (SMT solver unavailable)✅ 1 site
W1080Compile-time proof downgradedWarningNoThe constraint cannot be proven at compile-time; downgraded to a runtime check⚠ Not yet emitted
W1082Ownership analysis degradedWarningNoownership analysis degraded: this compilation has no body checker (type ledger and call-ownership table missing), so ownership was judged against an empty ledger and borrow conflicts were not checked✅ 1 site
W1090Obligation produced but never consumedWarningYesobligation field \` was produced in {file} but never consumed: {detail}`✅ 2 sites

std-Layer Runtime Codes ​

The codes below are not in the define_codes! registry: standard library native functions construct them at run time through error_new("CODE", …), so they never appear in the result of ErrorCodeDefinition::find(). locales/*.json still carries wording for them, so users may still see them in the terminal.

CodeNameCategoryTemplateEmission sites
E6009Invalid Range stepstd runtimeInvalid Range step: step = {step}src/std/range.rs:213, src/std/range.rs:344 and 3 more sites
E6010Integer parsing failedstd runtimeInteger parsing failed: {input}src/std/result.rs:31, src/std/string.rs:958
E6011Floating-point parsing failedstd runtimeFloating-point parsing failed: {input}src/std/result.rs:32, src/std/string.rs:983 and 3 more sites
E6012Invalid code pointstd runtimeIllegal code point: {input}src/std/result.rs:33, src/std/string.rs:1028
E6013JSON parse failedstd runtimeJSON parse failed: {detail}src/std/json.yx:485, src/std/result.rs:34

Notation ​

  • span exempt: when it is true, the diagnostic may carry no source location (internal errors, runtime diagnostics, and the like). A non-exempt code is rejected when it has neither an explicit .at() nor a walk context (panic in debug builds, E8001 in release builds).
  • Emission site ⚠ Not yet emitted: the code is retained in the registry, but non-test code never calls it, so users cannot trigger it. Code numbers are never recycled, so a diagnostic in an old artifact is never reused for a different meaning.
  • std-layer runtime codes: see the previous section; they are not counted in the registry statistics.

Look Up a Single Code ​

bash
yx explain E1001
yx explain E1001 --json

Querying from Rust ​

rust
use yaoxiang::util::diagnostic::{ErrorCodeDefinition, I18nRegistry};

let i18n = I18nRegistry::default();

if let Some(code) = ErrorCodeDefinition::find("E1001") {
    println!("Title: {}", i18n.get_title(&code));
    if let Some(help) = i18n.get_help(&code) {
        println!("Help: {}", help);
    }
}