Skip to content

エラーコードリファレンス ​

YaoXiang コンパイラは、エラーコードを使用してさまざまな種類の診断情報を識別します。エラーコードは番号範囲でグループ化されており、各コードは特定のエラーシナリオに対応しています。


E0xxx -- 字句解析と構文解析 ​

字句解析器(Lexer)と構文解析器(Parser)のフェーズで生成されるエラーです。

エラーコードテンプレート説明
E0001Invalid character: '{char}'無効な文字
E0002Invalid number literal: '{literal}'無効な数値リテラル
E0003Unterminated string starting at line {line}終端されていない文字列
E0004Invalid character literal: '{literal}'無効な文字リテラル
E0010Expected {expected}, found {found}予期されたトークン
E0011Unexpected token: '{token}'予期しないトークン
E0012Invalid syntax: {reason}無効な構文
E0013Mismatched {bracket_type}: opened at line {open_line}, column {open_col}, not closed一致しない括弧
E0014Missing semicolon after {statement}セミコロンの欠落

E1xxx -- 型検査 ​

型検査フェーズで生成されるエラーで、変数の型、関数呼び出し、パターンマッチング、ジェネリクスのインスタンス化、並行セマンティクス、エラー伝播などをカバーします。

エラーコードテンプレート説明
E1001Unknown variable: '{name}'不明な変数
E1002Expected type '{expected}', found type '{found}'型の不一致
E1003Unknown type: '{type}'不明な型
E1010Function '{func}' expects {expected} arguments, found {found}引数の数が一致しない
E1011Parameter type mismatch: expected '{expected}', found '{found}'引数の型が一致しない
E1012Return type mismatch: expected '{expected}', found '{found}'戻り値の型が一致しない
E1013Function not found: '{func}'関数が見つからない
E1020Cannot infer type for '{expr}'型を推論できない
E1021Type inference conflict: {reason}型推論の競合
E1030Pattern non-exhaustive: missing patterns {patterns}パターンが網羅的でない
E1031Unreachable pattern: '{pattern}'到達不能パターン
E1040Operation '{op}' is not supported for type '{type}'操作は型でサポートされていない
E1041Index out of bounds: valid range is 0..{max}, found {index}インデックスが範囲外
E1042Field '{field}' not found in struct '{struct}'フィールドが見つからない
E1050Logical operation requires boolean operands, found '{left}' and '{right}'ブール演算子が必要
E1051Logical NOT requires boolean operand, found '{type}'論理 NOT はブール演算子が必要
E1052Cannot dereference type '{type}', expected pointer type無効なデリファレンス
E1053Cannot access field on non-struct type '{type}'構造体でない型へのフィールドアクセス
E1054Condition must be boolean, found '{type}'条件の型が一致しない
E1055Constraint type '{type}' can only be used in generic contextジェネリックでない文脈での制約
E1060Expected {expected} type argument(s), found {found}型引数の数が一致しない
E1061Cannot instantiate generic type with given argumentsジェネリック型をインスタンス化できない
E1081`?` is only allowed inside functions returning Result? は Result を返す関数内でのみ使用可能
E1082`?` requires a Result expression, found '{type}'? は Result 式にのみ使用可能
E1083Result error type mismatch for `?`: expected '{expected}', found '{found}'? のエラー型が一致しない
E1090Type: Type = Type言うべからざるもの(イースターエッグ)
E1091Generic meta-type self-reference is not allowed: '{decl}'無効なジェネリックメタ型
E1062Const generic constraint violation: {reason}const ジェネリック制約違反
E1064Invalid binding position(s) {positions} for function with {total} parameter(s)バインディング位置のインデックスが無効(RFC-004)
E1095Unknown interface: '{name}'不明なインタフェース(RFC-011a)
E1096Interface '{name}' expects {expected} type argument(s), found {found}インタフェースの実引数の数が一致しない
E1097Interface member '{member}' conflicts with field of type '{type}'インタフェースのメンバーとフィールド名の競合
E1098Type '{type}' does not implement '{interface}.{method}'インタフェースメソッドが未実装
E1099Signature mismatch for '{type}.{method}': expected '{expected}', found '{found}'インタフェースメソッドのシグネチャが一致しない
E1100Duplicate implementation of '{type}.{method}' (override is not allowed)同じシグネチャのメソッドの重複実装(上書き禁止)
E1101Type '{type}' does not implement interface '{interface}' and cannot enter this existential position型がインタフェースを実装していない(存在型のメンバチェック)

E2xxx -- 意味解析 ​

意味解析フェーズで生成されるエラーで、スコープ、変数のライフタイム、所有権、関数シグネチャの解析などをカバーします。

エラーコードテンプレート説明
E2001Variable '{name}' is not in scopeスコープエラー
E2002Duplicate definition: '{name}' is already defined in this scope重複定義
E2003Ownership constraint violated: {reason}所有権エラー
E2010Cannot assign to immutable variable '{name}'不変変数への代入
E2011Use of uninitialized variable '{name}'未初期化変数の使用
E2012Mutability conflict: cannot use mutable reference in immutable context可変性の競合
E2013Cannot shadow existing variable '{name}'変数のシャドーイング
E2014'{name}' has been moved and cannot be used移動済み変数の使用
E2090Invalid signature: {reason}無効なシグネチャ
E2091Invalid signature: unknown type '{type_name}'シグネチャの不明な型
E2092Invalid signature: missing '->'シグネチャに矢印がない
E2093Invalid signature: duplicate parameter '{name}'重複する引数名
E2094Invalid signature: generic '{name}' shadows outer genericジェネリックパラメータのシャドーイング
E2095Invalid signature: parameter '{name}' shadows genericパラメータ名によるジェネリックのシャドーイング

E4xxx -- ジェネリクスとトレイト ​

ジェネリック制約とトレイトシステムに関連するエラーです。

エラーコードテンプレート説明
E4001Type '{type}' does not satisfy the trait bound '{trait}'ジェネリック制約違反
E4002Trait '{trait}' not foundトレイトが見つからない
E4003Missing implementation for trait '{trait}' for type '{type}'トレイトの実装が欠落
E4004Conflicting trait implementations for '{trait}'トレイトの実装が競合
E4005Associated type '{assoc_type}' not found in '{container}'関連型が見つからない

E5xxx -- モジュールとインポート ​

モジュールシステムとインポートに関連するエラーです。

エラーコードテンプレート説明
E5001Module '{module}' not foundモジュールが見つからない
E5002Failed to import module '{module}': {reason}インポートエラー
E5003Export '{export}' not found in module '{module}'エクスポートが見つからない
E5004Circular dependency detected: {path}循環依存
E5005Invalid module path: '{path}'無効なモジュールパス
E5006Duplicate import: '{name}' is already imported重複インポート
E5007Module '{module}' exports: {available}モジュールのエクスポートのヒント

E6xxx -- ランタイム ​

ランタイムフェーズで生成されるエラーです。

エラーコードテンプレート説明
E6001Division by zero in expression: {expr}ゼロ除算エラー
E6003Array index out of bounds: valid range is 0..{max}, found {index}配列のインデックスが範囲外
E6004Stack overflow: recursion depth exceeded limit {limit}スタックオーバーフロー
E6005Assertion failed: {condition}アサーション失敗
E6006Function not found: '{func}'関数が見つからない(ランタイム)
E6007Runtime error: {message}ランタイムエラー

E7xxx -- I/O とシステム ​

I/O 操作とシステムレベルのエラーです。

エラーコードテンプレート説明
E7001File not found: '{path}'ファイルが見つからない
E7002Permission denied: '{path}'アクセス拒否
E7003I/O error: {reason}I/O エラー
E7004Network error: {reason}ネットワークエラー

E8xxx -- 内部コンパイラエラー ​

コンパイラの内部エラーで、通常はコンパイラ自体のバグを示します。この種の問題が発生した場合は、GitHub Issues で報告してください。

エラーコードテンプレート説明
E8001Internal compiler error: {message}内部コンパイラエラー
E8002Unexpected compiler panic: {reason}予期しないパニック
E8003Compiler phase error: {phase} - {message}コンパイラフェーズエラー

W1xxx -- 警告 ​

デッドコード検出に関連する警告です。警告はコンパイルを阻止しませんが、コードに潜在的な問題があることを示します。

エラーコードテンプレート説明
W1001Unused exported function: '{name}'未使用のエクスポート関数
W1002Unused exported type: '{name}'未使用のエクスポート型
W1003Unused import: '{name}'未使用のインポート
W1004Unused exported variable: '{name}'未使用のエクスポート変数
W1005Unused exported method: '{name}'未使用のエクスポートメソッド
W1063const generic constraint cannot be evaluated: `{constraint}` ({var} = {value})const ジェネリック制約を評価できない
W1080Constraint cannot be proven at compile-time, degraded to runtime checkコンパイル時証明のランタイムチェックへの降格

合計 118 個の診断コード(111 個のエラーコード + 7 個の警告コード)。define_codes! レジストリ(src/util/diagnostic/codes/)を信頼できる情報源としています。各コードの完全な登録リストはレジストリに従ってください。このページでは、よく使われるコードを族ごとに列挙しています。