# Error codes

Every diagnostic code Oska reports, with a program that fails with it and the same program fixed. `oskac explain <code>` prints an entry offline.

All of them are in [codes.json](https://oskalang.dev/codes.json) as data.

- [E0001](https://oskalang.dev/codes/E0001.md): A character that starts no token, such as `$`
- [E0002](https://oskalang.dev/codes/E0002.md): A string literal that is not closed before the end of the file
- [E0003](https://oskalang.dev/codes/E0003.md): An invalid escape in a string: a backslash followed by anything but one of the escapes
- [E0004](https://oskalang.dev/codes/E0004.md): A `{` or `}` in a sink literal such as `sql"..."`, which never interpolates
- [E0005](https://oskalang.dev/codes/E0005.md): A `;`: Oska has no semicolons, because a line break ends a statement
- [E0100](https://oskalang.dev/codes/E0100.md): The parser expected an expression, a type, or a pattern and found something else
- [E0101](https://oskalang.dev/codes/E0101.md): The parser expected a specific token, such as a `)`, and found another
- [E0102](https://oskalang.dev/codes/E0102.md): A `{...}` hole in a string that holds more than a name or a field path, such as `{n + 1}`
- [E0103](https://oskalang.dev/codes/E0103.md): A bare `{ .
- [E0104](https://oskalang.dev/codes/E0104.md): A `let` or `var` without an initializer
- [E0105](https://oskalang.dev/codes/E0105.md): A chained comparison such as `a < b < c`
- [E0106](https://oskalang.dev/codes/E0106.md): An assignment whose left side is not a name or a field path, such as `x + 1 = 2`
- [E0107](https://oskalang.dev/codes/E0107.md): A statement at module level, where only items are allowed
- [E0110](https://oskalang.dev/codes/E0110.md): An `ensures` clause without a `|r|` binding for the return value
- [E0111](https://oskalang.dev/codes/E0111.md): A `self` or `var self` receiver that is not the first parameter
- [E0112](https://oskalang.dev/codes/E0112.md): `var` on a parameter other than the `self` receiver
- [E0113](https://oskalang.dev/codes/E0113.md): A `where` clause
- [E0120](https://oskalang.dev/codes/E0120.md): A missing comma between the declared fields of a struct or the variants of an enum
- [E0130](https://oskalang.dev/codes/E0130.md): A glob import such as `use std.sql.*`
- [E0131](https://oskalang.dev/codes/E0131.md): A renaming import such as `use std.sql.query as q`
- [E0132](https://oskalang.dev/codes/E0132.md): An attribute name outside the fixed set, which holds only `integration`
- [E0133](https://oskalang.dev/codes/E0133.md): `unsafe`, which Oska does not have
- [E0140](https://oskalang.dev/codes/E0140.md): An or-pattern such as `A | B`
- [E0141](https://oskalang.dev/codes/E0141.md): A range pattern such as `1..5`
- [E0142](https://oskalang.dev/codes/E0142.md): An `@` binding such as `v @ Some(_)`
- [E0143](https://oskalang.dev/codes/E0143.md): A comma between `match` arms
- [E0150](https://oskalang.dev/codes/E0150.md): A `self` or `var self` receiver on a function outside an `impl` or `trait` block
- [E0151](https://oskalang.dev/codes/E0151.md): `pub` on an `impl` block
- [E0160](https://oskalang.dev/codes/E0160.md): A string pattern with an interpolation hole
- [E0161](https://oskalang.dev/codes/E0161.md): A test name with an interpolation hole
- [E0162](https://oskalang.dev/codes/E0162.md): `pub` on a trait method
- [E0163](https://oskalang.dev/codes/E0163.md): `pub test`
- [E0164](https://oskalang.dev/codes/E0164.md): `pub use`
- [E0165](https://oskalang.dev/codes/E0165.md): `#[integration]` on an item other than a `test`
- [E0170](https://oskalang.dev/codes/E0170.md): `#[capability]` on an item other than a `struct`, in the prelude
- [E0200](https://oskalang.dev/codes/E0200.md): Unknown type or trait name, or a qualified path such as `sql.Query` whose first segment is not a module bound by a plain `use`
- [E0201](https://oskalang.dev/codes/E0201.md): A trait where a type is expected (`x: Display`), or a type where a trait is expected (`T: Int`)
- [E0202](https://oskalang.dev/codes/E0202.md): A type or trait name declared twice in the module, or one that redeclares a prelude name; a free function declared twice, or one that redeclares a prelude function (`dbg`, `todo`); or a method or associated function declared twice for one type, across all of its inherent `impl` blocks
- [E0210](https://oskalang.dev/codes/E0210.md): A struct or enum whose own fields name a capability-bearing type (a built-in capability, a `cap` type, or a `cap fn`, including inside written type arguments such as `List<Stdout>`) is not declared `cap`
- [E0211](https://oskalang.dev/codes/E0211.md): A `main` parameter whose type is not a built-in capability or `Args`
- [E0212](https://oskalang.dev/codes/E0212.md): `main` returns something other than `()` or `Result<(), E>` (spans the return type), or `E` has no `impl Display` (spans `E`)
- [E0213](https://oskalang.dev/codes/E0213.md): A type, enum variant, trait, or type parameter name that does not start with an uppercase letter (ADR 0005)
- [E0214](https://oskalang.dev/codes/E0214.md): A function, method, field, parameter, or local variable (`let`, `var`, `for`) name that starts with an uppercase letter (ADR 0005)
- [E0215](https://oskalang.dev/codes/E0215.md): A struct or enum with no base case: every way to build it contains itself, as in `struct Loop { me: Loop }`
- [E0216](https://oskalang.dev/codes/E0216.md): A call to `dbg(...)` when checking with `--release`
- [E0217](https://oskalang.dev/codes/E0217.md): A `main` parameter whose type is a directory or file capability: `Dir`, `DirRead`, `DirWrite`, `FileRead`, or `FileWrite`
- [E0218](https://oskalang.dev/codes/E0218.md): A `requires` or `ensures` clause on a method of `impl Trait for Type`
- [E0219](https://oskalang.dev/codes/E0219.md): A `requires` or `ensures` clause on `main`
- [E0220](https://oskalang.dev/codes/E0220.md): Type mismatch: an expression's type differs from the type expected there
- [E0221](https://oskalang.dev/codes/E0221.md): Unknown value name, or `self` outside a method with a receiver
- [E0222](https://oskalang.dev/codes/E0222.md): Integer literal out of range for its type, such as `300` as a `U8`
- [E0223](https://oskalang.dev/codes/E0223.md): Operator not defined for its operand's type: arithmetic and ordering need numbers (`+` is not for strings), unary `-` needs a signed number, `..` needs integers
- [E0224](https://oskalang.dev/codes/E0224.md): Wrong number of arguments in a call or construction
- [E0225](https://oskalang.dev/codes/E0225.md): Argument label that does not match its parameter or field, or a label on a positional field
- [E0226](https://oskalang.dev/codes/E0226.md): Named field constructed without its label
- [E0227](https://oskalang.dev/codes/E0227.md): Unknown field, or a method used without calling it
- [E0228](https://oskalang.dev/codes/E0228.md): Unknown method, variant, or associated function, or an associated function called on a value
- [E0229](https://oskalang.dev/codes/E0229.md): Assignment to something that is not a `var` binding: a `let` binding, a parameter, or a field of `self` in a method without `var self`
- [E0230](https://oskalang.dev/codes/E0230.md): Mutating method (`var self`) called on something that is not a `var` binding
- [E0231](https://oskalang.dev/codes/E0231.md): Call of a value that is not a function
- [E0232](https://oskalang.dev/codes/E0232.md): `break` or `continue` outside a loop
- [E0233](https://oskalang.dev/codes/E0233.md): A type that inference cannot work out, such as `let xs = List.new()` with no later use
- [E0234](https://oskalang.dev/codes/E0234.md): A type name used as a value, or a type that cannot be constructed
- [E0235](https://oskalang.dev/codes/E0235.md): `for` over a value that is not a `List` or a range
- [E0240](https://oskalang.dev/codes/E0240.md): An expression statement whose `Result` value is dropped
- [E0241](https://oskalang.dev/codes/E0241.md): `?` on a value that is neither a `Result` nor an `Option`
- [E0242](https://oskalang.dev/codes/E0242.md): `?` on a `Result` whose error type is not the enclosing function's error type, with no `impl From` to convert it
- [E0243](https://oskalang.dev/codes/E0243.md): `?` in a function (or closure) that does not return the same kind: an `Option` in a function returning `Result` (convert with `.ok_or(err)?`), a `Result` in one returning `Option`, or either in one returning neither
- [E0250](https://oskalang.dev/codes/E0250.md): A pattern that names no variant or struct
- [E0251](https://oskalang.dev/codes/E0251.md): A constructor pattern with the wrong number of fields, such as `Some` or `Shape.Square(a, b)`
- [E0252](https://oskalang.dev/codes/E0252.md): A named field matched without its label (`Shape.Circle(r)`) or with the wrong one, or a label on a positional field
- [E0253](https://oskalang.dev/codes/E0253.md): A `match` that is not exhaustive, checked with the pattern-usefulness algorithm through nested constructor patterns
- [E0254](https://oskalang.dev/codes/E0254.md): An unreachable arm: the earlier unguarded arms already match every value it does, as with any arm after a `_` or binding arm
- [E0260](https://oskalang.dev/codes/E0260.md): A method called on a value of a generic parameter whose bounds provide no method of that name
- [E0261](https://oskalang.dev/codes/E0261.md): An `impl Trait for Type` that leaves out a required method (one without a default body)
- [E0262](https://oskalang.dev/codes/E0262.md): An `impl` method whose signature differs from the trait's, once `Self` and the trait's arguments are replaced
- [E0263](https://oskalang.dev/codes/E0263.md): An `impl Trait` method that the trait does not declare
- [E0264](https://oskalang.dev/codes/E0264.md): A method call that two or more of the receiver's traits (or a parameter's bounds) provide, when the type's own `impl` does not
- [E0265](https://oskalang.dev/codes/E0265.md): A type that does not implement a trait it must: `==` and `!=` need `Eq`; a call must satisfy the callee's bounds; a qualified call `Trait.method(x)` needs `x`'s type to implement `Trait`; an interpolation hole needs `Display`
- [E0270](https://oskalang.dev/codes/E0270.md): A `cap fn` used where a plain `fn` is expected: a closure that captures a capability-bearing value (a built-in capability, a `cap` type, a `cap fn`, or a container of one, including a capability-bearing `self`), or a `cap fn` value passed on
- [E0271](https://oskalang.dev/codes/E0271.md): Construction of a prelude struct with private fields, such as a built-in capability (`Stdout(handle: 1)`) or `Args`
- [E0272](https://oskalang.dev/codes/E0272.md): Reading a private field of a prelude type, such as `out.handle`
- [E0273](https://oskalang.dev/codes/E0273.md): A call of `read_to_string`, `list_dir`, `write`, or `create_dir` on `Fs`, `FsRead`, or `FsWrite`, whether written `read.read_to_string(path)`, qualified as `FsRead.read_to_string(read, path)`, or taken as a value
- [E0274](https://oskalang.dev/codes/E0274.md): A type argument breaks what a generic body assumes of its type parameter (see above): a capability-bearing type for a parameter that a contract uses or that a plain `fn` closure captures, or a type holding a `Scope` for a parameter that an unscoped closure captures
- [E0280](https://oskalang.dev/codes/E0280.md): A contract clause (`requires` or `ensures`) calls a function that is not pure: one with a capability-bearing parameter or receiver, or a `cap fn` value
- [E0281](https://oskalang.dev/codes/E0281.md): A `requires` or `ensures` condition whose type is not `Bool`
- [E0282](https://oskalang.dev/codes/E0282.md): A `?` or a `return` directly inside a `requires` or `ensures` expression, outside any closure
- [E0290](https://oskalang.dev/codes/E0290.md): Two `impl Trait for Type` that overlap: some instantiation of each implements the same trait, with the same arguments, for the same type, as with `impl<T> Display for Box<T>` and `impl Display for Box<Int>`
- [E0291](https://oskalang.dev/codes/E0291.md): An inherent `impl` for a prelude type, such as `impl FsRead { .
- [E0292](https://oskalang.dev/codes/E0292.md): A `Scope` handle that could outlive its `scope` block: `Scope` in a function's or method's return type, in a struct or enum field's type, or in the type of a `scope` block's value, including inside wrappers such as `Option<Scope>` or `List<Scope>`
- [E0293](https://oskalang.dev/codes/E0293.md): A call to `todo()` when checking with `--release`
- [E0294](https://oskalang.dev/codes/E0294.md): A `use` whose path does not start with `std.`: only the standard library can be imported
- [E0295](https://oskalang.dev/codes/E0295.md): A `use std.*` of a module that does not exist
- [E0300](https://oskalang.dev/codes/E0300.md): Untrusted text in a structural position: an `Untrusted<String>` used where trusted `String` is required, such as a `String` parameter, field, or return type
- [E0310](https://oskalang.dev/codes/E0310.md): A sink literal, such as `sql"..."`, whose module is not imported
- [E0311](https://oskalang.dev/codes/E0311.md): A sink literal whose tag no `std.*` module provides, such as `sqll"..."`
- [E0312](https://oskalang.dev/codes/E0312.md): A name that the module does not export, in a `use` brace group (`use std.sql.{Query}`) or a qualified path (`sql.Query`)
- [E0320](https://oskalang.dev/codes/E0320.md): `Untrusted<T>` where `T` is not text, such as `Untrusted<Int>`, `Untrusted<List<String>>`, or `Untrusted<T>` for a generic `T`
- [E0340](https://oskalang.dev/codes/E0340.md): A module's export written unqualified, such as `Db` after a plain `use std.sql`, which imports only the module
- [E0341](https://oskalang.dev/codes/E0341.md): Text where a sink literal type is required, such as a `String`, an `Untrusted<String>`, a string literal, or an interpolated string passed to `Db.query` as query text
- [E0350](https://oskalang.dev/codes/E0350.md): A `Secret` interpolated into a string, such as `"Bearer {key}"`, or a value that holds one anywhere inside, such as a `List<Secret<String>>`, an `Option<Secret<String>>`, or a struct with a `Secret` field
- [E0351](https://oskalang.dev/codes/E0351.md): A `Secret` compared with `==` or `!=`, on either side
- [E0352](https://oskalang.dev/codes/E0352.md): A `Secret` used where it must be `Display`: a `Display` bound, or a call to `.to_string()`
- [E0360](https://oskalang.dev/codes/E0360.md): A name declared by an imported `std` module but not exported by it, written unqualified
- [E0370](https://oskalang.dev/codes/E0370.md): `main` declares a capability that has no runtime yet: `Net`, `NetConnect`, `NetListen`, `Spawn`, or `Sched`
- [E0371](https://oskalang.dev/codes/E0371.md): The program imports a `std` module that has no runtime yet: `std.proc` or `std.sql`, used or not
- [E0380](https://oskalang.dev/codes/E0380.md): The program uses something the interpreter cannot run yet: a construct the checked program cannot express, a call of a prelude function with no runtime implementation, or a parameter of `main` that is neither a capability nor `Args`
- [P0001](https://oskalang.dev/codes/P0001.md): Integer overflow: the result of `+`, `-`, `*`, `/`, or unary `-` does not fit its type, as with a `U8` `0 - 1` or an `I8` `-128 / -1`
- [P0002](https://oskalang.dev/codes/P0002.md): Index out of bounds: `List.at` was given an index below 0 or not below the list's length
- [P0003](https://oskalang.dev/codes/P0003.md): `todo()` reached
- [P0004](https://oskalang.dev/codes/P0004.md): Division by zero: the right operand of `/` or `%` is zero
- [P0005](https://oskalang.dev/codes/P0005.md): `spawn` on a finished scope: the handle's `scope` block has ended, and work never runs outside a scope
- [P0006](https://oskalang.dev/codes/P0006.md): Precondition violated: a `requires` clause of the function called is false, so the caller broke the contract
- [P0007](https://oskalang.dev/codes/P0007.md): Postcondition violated: an `ensures` clause of the function that returned is false, so the function broke its promise
- [P0010](https://oskalang.dev/codes/P0010.md): `t.assert(cond)` was given `false`
- [P0011](https://oskalang.dev/codes/P0011.md): `t.assert_eq(actual, expected)` was given two values that differ through `Eq`
- [P0012](https://oskalang.dev/codes/P0012.md): `t.assert_ne(actual, other)` was given two equal values
- [P0013](https://oskalang.dev/codes/P0013.md): `t.fail(message)` was called
- [P0020](https://oskalang.dev/codes/P0020.md): `Env.secret` asked for a variable the environment does not set
- [P0021](https://oskalang.dev/codes/P0021.md): Calls nest too deep: runaway recursion
- [P0035](https://oskalang.dev/codes/P0035.md): `String.slice` was given indices out of bounds: a start or end below 0 or past the text's length in characters, or a start past the end
- [P0036](https://oskalang.dev/codes/P0036.md): `String.repeat` was given a negative count
- [P0037](https://oskalang.dev/codes/P0037.md): `String.repeat` would build a text over 256 MiB, so the interpreter panics instead of running out of memory
