Skip to content

診断コード

コンパイラとツールの診断にはコードが振られています。エラーで止まったときは、ここでコードを引くと、何が起きたかと関係するページが分かります。

  • エラーは E + 4桁、警告は W + 4桁です。一度振った番号は診断を廃止しても使い回しません。
  • 番号は段ごとの帯に分けます。警告も同じ帯を使います(W03xx は型の警告)。
  • 文面は英語です。文面は仕様の一部ではなく、改善のために変わることがあります。コードは変わりません。
fn main() {
user = 1
x = usr
y: Int = "a"
}
Terminal window
$ emela check main.emel
error[E0211]: cannot find value `usr` in this scope
╭─[ main.emel:3:7 ]
│
3 │ x = usr
│ ─┬─
│ ╰───
───╯
= help: did you mean `user`?
error[E0301]: type mismatch: expected `Int`, found `String`
╭─[ main.emel:4:12 ]
│
4 │ y: Int = "a"
│ ─┬─
│ ╰───
───╯
2 errors
  • 診断は標準エラーに出し、間を空行で区切ります。
  • 位置は ╭─[ パス:行:桁 ] の枠で示します。位置がファイル全体のときは ─[ パス ] の1行にします。
  • 注記は = note: ...、助言は = help: ... と出します。
  • コードのない診断は error: ... と出します。
  • 最後の行は N errors、警告もあれば N errors, M warnings です(1件なら単数形)。
  • 色は標準エラーが端末で、環境変数 NO_COLOR が空か未設定のときだけ付けます。
  • 診断にエラーがあれば、コマンドは終了コード 1 で終わります。警告だけなら 0 です。
帯段
E01xx字句と構文(E0101〜E0109 は字句、E0110〜E0189 は構文、E0190〜E0199 は字句の追加分)
E02xxモジュール、import、プロジェクトの構成
E03xx型
E04xxeffect、handler、layer、capture set
E05xx〜E08xx予約(Trait と derive、外部関数、テストなどに、使うときに割り当てる)
E09xxツール(入出力、node など)

文面の例はその診断の代表的な文面です。かっこの中のリンクは規則を説明しているページです。

コード内容文面の例
E0101文字列が閉じていないunterminated string literal
E0102補間 #{ が閉じていないunterminated interpolation
E0103どの名前のクラスにも合わない(字句と予約語)invalid name `Http_client`: not a lower, type, or upper name
E0104数値の形になっていないinvalid number literal `1e9`
E0105認識できない文字unrecognized character `é`
E0106\ の後ろに文字がない(行末の \。複数行の文字列の中を含む)missing character after `\`
E0107使えないエスケープunknown escape sequence `\q`
E0108\u{...} の誤り(形の崩れ、サロゲート、10FFFF 超え)`\u{D800}` is a surrogate, not a Unicode scalar value
E0109複数行の文字列の形の誤り(開く """ の後が改行でない、閉じる """ が行に1つでない、閉じる行より浅いインデント)expected a newline after the opening `"""`
E0110来るはずのトークンがない。文面には期待したトークンの表示名が入る(記号と予約語はバッククォートで囲み、名前とリテラルは lower name integer literal のような種類名、入力の終わりは end of file)expected `)`
E0111型が来るはずの位置に型がないexpected type
E0112要素が1つのタプル(型・パターン・式の (a,)、型とパターンの (a))a tuple type needs at least two elements
E0113パターンが来るはずの位置にパターンがないexpected pattern
E0114.. の後ろに要素がある`..` must come last
E0115リストの .. の前に要素がない([..rest])`..` needs at least one element before it
E0116欠番(パターンの負の数の暫定の診断だった。0.20.1 で負の数を書けるようにして廃止)
E0117パターンの文字列に補間があるstring interpolation is not allowed in a pattern
E0118式が来るはずの位置に式がないexpected expression
E0119比較演算子の連鎖(a < b < c)comparison operators cannot be chained
E0120名前付き引数の後ろの位置引数positional arguments cannot follow named arguments
E0121括弧のない use X.op()wrap `use` in parentheses to call its operations: `(use X).op()`
E0122文・腕・宣言の後ろに改行か } がないexpected newline or `}` after statement
E0123パターンの外の _`_` can only be used in patterns
E0124パターンの外の、式のない ..`..` without an expression can only be used in patterns
E0125束縛の左辺がパターンとして読めない(a + b = 1)invalid left-hand side of binding: expected a pattern
E0126宣言が来るはずの位置に宣言がないexpected declaration
E0127宣言の後ろの import(モジュール)imports must come before declarations
E01281つのバリアントで名前付きと名前なしのフィールドを混ぜた(文法)a variant cannot mix named and positional fields
E0129trait の本体の導出規則(導出規則の構文が決まるまでの暫定)derive rules in traits are not supported yet
E0130@external がない: 本体のない fn、トップレベルの suspend fn、フィールドのない type(文法)a function without a body must be `@external`
E0131opaque を type / enum 以外に付けた、または pub なしで付けた`opaque` can only be used on `type` and `enum`
E0132バリアントのない enuman enum needs at least one variant
E0133impl に pub や注釈を付けた(文法 の impl_decl)`impl` cannot have `pub` or annotations
E0134handler の操作の引数に型を書いた(handler_item)handler operation parameters take their types from the effect
E0135impl と handler の fn に本体がないthis function needs a body
E0136impl の fn に戻り値、fails、use を書いた(impl_item)impl methods take their signature from the trait
E0137エフェクトの操作に use 節を書いた(文法 の op_sig)effect operations cannot have a `use` clause
E0138@external の引数の形の誤り(ターゲットの名前がない、文字列でない引数、文字列が1つか2つでない、文字列の補間)(外部関数)expected `@external(target, "name")`
E01391つの fn に同じターゲットの @external が2つ以上ある(外部関数)duplicate `@external` for target `js`
E0140知らないターゲットの名前(今は js、wasm、c)(外部関数)unknown target `node`
E0141@external type の注釈に引数を付けた(外部関数)`@external` on a type takes no arguments
E0142match を前置で書いた(パターンマッチ)`match` comes after the value: write `value match { ... }`
E0143〜構文のエラーパーサで割り当てて、この表に足す

E02xx と W02xx モジュール、import、プロジェクトの構成

Section titled “E02xx と W02xx モジュール、import、プロジェクトの構成”
コード内容文面の例
E0201ファイル名がモジュール名にならない(モジュール)file name `Foo` cannot be a module name: not lower snake_case
E0202ディレクトリ名がモジュール名にならないdirectory name `My-Dir` cannot be a module name: not lower snake_case
E0203予約されたモジュール名(ソースのルート直下の prelude.emel、core のモジュールと同じ名前のファイル、std.emel と std/)(モジュールと名前の解決)module name `Prelude` is reserved
E0204モジュールの重複(大文字小文字の違いだけのものを含む)duplicate module `Http.Client`
E0205import 先のモジュールがないundefined module `Http.Clinet`
E0206import の循環(自己 import を含む)import cycle: `A` -> `B` -> `A`
E0207ディレクトリを渡したが Pome.toml が見つからないno `Pome.toml` found in `proj` or its ancestors
E0208渡したファイルかディレクトリがソースのルートの外にある(モジュールと名前の解決、CLI)file `scripts/x.emel` is outside the source root `src` / directory `scripts` is outside the source root `src`
E0209エントリが見つからない(build と run のみ)entry `src/main.emel` not found
E0210エントリがモジュールにならないentry `src/Main.emel` is not a module
E0211未定義の名前undefined name `usr`
E0212モジュール、Trait、エフェクトに、その名前の項目がないmodule `Http.Client` has no item `gett`
E0213同じ名前空間での定義の重複duplicate definition of `User`
E0214pub でない定義を、他のモジュールから参照した`parse_raw` is private to `Email`
E0215opaque な型を定義モジュールの外で構築した(モジュール)cannot construct opaque type `Email` outside its module
E0216opaque な型を定義モジュールの外でパターンに書いた(モジュール)cannot match on opaque type `Email` outside its module
E0217名前は見つかったが、その位置に書けない種類だったexpected an error, found type `User`
E0218. の左の名前が、モジュールと Trait の両方を指すambiguous name `Show`: both a module and a trait
E0219self か Self を、使えない場所に書いた`self` is only available in handlers, traits, and impls
E02201つのパターンか引数の並びで、同じ名前を2回束縛した`x` is bound more than once
E0221型の位置にエフェクトの名前を書いた。集合でない型引数の位置(List[Db])に書いたときも含む(型と効果の体系)effect `Logger` cannot be used as a type
E0222部分更新の呼び出し先が、構成子1つのもの(type、error、フィールドのある handler)でない(データ)cannot update enum variant `Circle` with `..`
E0223部分更新で、変えるフィールドを位置で書いた(データ)fields to update must be named: `field: value`
E0224@intrinsic を同梱の core のソースの外で使った(字句と予約語)`@intrinsic` can only be used in the bundled core library
E0225@intrinsic を本体のない fn 以外に付けた(字句と予約語)`@intrinsic` can only be used on a function without a body
E0226@test を、引数のある fn、本体のない fn、トップレベルの fn 以外に付けた、または @test に引数を付けた(字句と予約語)test function `takes` cannot take parameters
E0227テスト関数を、テスト関数でない fn や const から参照した(テスト)test function `adds` can only be used from test functions
E0228@internal の fn を、同梱の core のモジュールの外から参照した(字句と予約語)function `Secret.peek` can only be used from the bundled core library
E0229@internal を、同梱の core の外か、トップレベルの fn 以外に付けた(字句と予約語)`@internal` can only be used in the bundled core library
E0230emela run のエントリに main がない(実行時の意味)entry `src/main.emel` has no `main` function
E0231const が名前だけで循環している(データ)constants refer to each other: `A` -> `B` -> `A`
E0232Pome.toml の [build].target が知らないターゲット(Pome)unknown target `node` in `[build].target`
W0201型名の型引数が、外側の同じ名前の型を隠す(字句と予約語)type parameter `Item` shadows type `Item`
W0202モジュールの定義か import が、Prelude の同じ名前を隠す`Some` shadows a Prelude name
コード内容文面の例
E0301型が合わないtype mismatch: expected `Int`, found `String`
E0302無限型infinite type: `?0` occurs in `List[?0]`
E0303match が網羅していない(パターンマッチ)non-exhaustive match: `Rect(_, _)` not covered
E0304型引数の数が合わない(組み込みの型、type / enum / error、型引数)wrong number of type arguments: `List` takes 1, found 2
E0305呼び出しの引数の数が合わない(型と効果の体系)wrong number of arguments: `connect` takes 2, found 3
E0306その名前の引数がない。引数名を持たない関数値を名前付き引数で呼んだときも含む(型と効果の体系)no parameter named `prot` in `connect`
E0307同じ引数を2回渡した。位置引数と名前付き引数で同じ仮引数を指したときも含む(型と効果の体系)argument `port` given more than once
E0308名前付きフィールドの構成子のパターンで、.. を書かずにフィールドを省いた(パターンマッチ)pattern `User` does not mention fields `id`, `email`
E0309構成子のパターンのフィールドの数が合わない(多すぎる、または .. なしで足りない)(型と効果の体系)pattern `Rect` has 2 fields, found 1
E0310数値が来るはずの位置に数値でない型(算術演算子、単項マイナス)(型と効果の体系)expected a number (`Int`, `Int64` or `Float`), found `String`
E0311整数リテラルが型の範囲を超えた(字句と予約語)integer literal `3000000000` is out of range for `Int`
E0312その名前のフィールドがないno field `nmae` on type `User`
E0313フィールドを持たない型のフィールドを参照したtype `Int` has no fields
E0314型が決まらない値のフィールドを参照したthe type of this value must be known to access field `name`
E0315opaque な型のフィールドを定義モジュールの外で参照した(モジュール)cannot access field `value` of opaque type `Email` outside its module
E0316トップレベルの fn の引数に型がない(関数)parameter `x` of a top-level function needs a type
E0317束縛のパターンが必ずは成功しない(パターンマッチ)refutable pattern in binding: `None` not covered
E0318本体のエラーが宣言の E に含まれない(-> T の未処理のエラー、fails にないエラー、const の値の失敗)(エラー)unhandled error `NotFound` / error `DbError` is not declared in `fails`
E0319エラーの型でない値を fail に渡した。1つのエラーの型の型引数をエラーでない型で具体化した(エラー)expected an error value, found `Int`
E0320escape の腕のパターンがエラーの構成子でない(エラー)escape arms must match an error constructor
E0321関数の値の E が、期待する関数型の E に含まれない(型と効果の体系)error set mismatch: expected `fails {}`, found `fails Timeout`
E0322効果の集合でない型引数に Immediate を付けた(型と効果の体系)`Immediate` can only constrain effect sets, but `A` is not used in `use`
E0323名前付き型の集合の型引数に、その種類のタグか集合の型引数でないものを書いた(型と効果の体系)`E` of `Handler` is an error set, found type `Int`
E0324集合でない型引数の位置に集合を書いた(型と効果の体系)expected a type, found a set: sets can only be passed to set type parameters
W0301冗長な腕(パターンマッチ)unreachable match arm
W0302escape の腕が受けるエラーが、元の式から起きない(型と効果の体系)error `Timeout` is never raised here

E04xx と W04xx effect、handler、layer、capture set

Section titled “E04xx と W04xx effect、handler、layer、capture set”
コード内容文面の例
E0401能力の値のエフェクトにその操作がない(型と効果の体系)effect `Logger` has no operation `infoo`
E0402本体の R が、宣言や文脈の許す R に含まれない(use 節、const、main、テスト関数)(エフェクト、型と効果の体系、テスト)effect `Logger` is not declared in `use` / effect `Clock` is not provided in `main`
E0403関数の値の R が、期待する関数型の R に含まれないeffect set mismatch: expected `use {}`, found `use Logger`
E0404handler が操作を全部は実装していない(エフェクト)handler `Half` does not implement operation `warn`
E0405handler が同じ操作を2回実装した(エフェクト)operation `info` is implemented more than once
E0406handler の操作の引数の数が宣言と違う(型と効果の体系)wrong number of parameters: operation `info` takes 1, found 2
E0407use を省略した @external の fn か @external suspend fn を、ハンドラの外で使った(外部関数)external function `console_log` can only be used in handlers
E0408能力の値を引数に渡した(エフェクト)a capability cannot be passed as an argument
E0409能力の値をデータ構造に入れた(エフェクト)a capability cannot be stored in a data structure
E0410能力の値を関数から返した(エフェクト)a capability cannot be returned from a function
E0411同じ with のハンドラの依存が循環している(型と効果の体系)handlers depend on each other: `Stamped` -> `Ticking` -> `Stamped`
E0412エントリからたどれる外部関数に、ビルド対象のターゲットの @external がない(外部関数)external function `wasm_now` has no `@external` for target `js`
E0413Async か Scope のハンドラを書いた(中断、型と効果の体系)handler `Runtime` cannot implement `Async`: only the runtime provides it / handler `MyScope` cannot implement `Scope`: only `Fiber.scope` provides it
E0414use Async を書いた(中断)`Async` has no operations and cannot be used with `use`
E0415ハンドラの操作の suspend の有無が、エフェクトの宣言と違う(中断)operation `now` is not a `suspend fn` in effect `Clock`
E0416Immediate を求める効果の集合が Immediate でない(型と効果の体系)effect `Clock` may suspend, but `R` of `update` must be `Immediate`
E0417fn の操作(suspend fn でないもの)の実装の本体の R が Immediate でなく、中断しうる呼び出しを含む(中断、型と効果の体系)calling `stamp` may suspend because it uses effect `Clock`, but operation `now` is not a `suspend fn`
E0418ハンドラの値を、そのハンドラの init の外で作った(リソース)handler `Counter` can only be constructed in its own `init`
E0419フィールドのあるハンドラに init がない(リソース)handler `NoInit` has fields but no `init`
E0420release が失敗しうる(リソース)`release` of handler `Counter` cannot fail, but this may fail with error `Boom`
E0421layer の中で同じエフェクトを2つのハンドラが供給する。layer の宣言で1回だけ報告する(型と効果の体系)effect `Logger` is provided by both `Counter` and `Quiet` in layer `Loud`
E0422layer が互いを含む。layer の宣言で1回だけ報告する(型と効果の体系)layers include each other: `LoopA` -> `LoopB` -> `LoopA`
E0423型引数のあるエフェクトの型引数を書いていない(use State、use 節、implements State)(エフェクト)missing type arguments for effect `State[S]`
E0424エフェクトの型引数を集合として使った(組み込みのエフェクトは除く。型と効果の体系)type parameter `E` of effect `Raise` is used as a set, but effect type parameters must be ordinary types
E0425Fiber.scope の値の型に Fiber か Deferred が含まれる(並行性)a `Fiber` cannot leave the `Fiber.scope` that started it
E0426利用者のエフェクトの操作に型引数を書いた(型と効果の体系)operation `wrap` cannot have type parameters: only built-in effects may declare them
E0427ビルド対象が c で、エントリからたどれる外部関数がコールバックを取るか返す(外部関数)external function `on_data` takes a callback, which target `c` does not support yet
E0428(欠番。C の suspend fn の外部関数を完了を後から知らせる形で認めたため)—
E0429ラベルの元のエフェクトがラベルか組み込みのエフェクト(ラベル)label `Nested` cannot stand for `Audit`: `Audit` is a label
E0430ラベルでないエフェクトを with に書いた、by の左に書いた(ラベル)effect `Log` is not a label: `with` takes a handler, a layer or a label
E0431by の右が、ラベルの元のエフェクトと別のエフェクトを担う(ラベル)label `Audit` stands for `Log`, but `OtherH` provides `Other`
E0432同じ with で同じラベルに2回 by を書いた(型と効果の体系)label `Audit` is given a provider more than once in this `with`
E0433ラベルのハンドラを書いた(ラベル)handler `AuditH` cannot implement label `Audit`
W0401with のラベルの項目が使われない(型と効果の体系)label `Audit` is listed here but never used
コード内容文面の例
E0901パスが見つからないpath `app` not found
E0902ファイルかディレクトリを読めないcannot read `src/a.emel`: permission denied
E0903出力を書き込めないcannot write `target/emela/js/main.mjs`
E0904node が見つからない、起動できないcannot start `node`
E0905JS の出力がまだない(0.20 の途中の段だけ)JS backend is not available yet
E0906JS の出力段が不正な出力を返した(処理系の内部の誤り)invalid output from the JS backend
E0907cc が見つからない、起動できない(CLI)cannot start `cc`
E0908出力した C のコンパイルに失敗した(処理系かホストの C の誤り)`cc` failed to compile `target/emela/c/main.c`