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 as data.
- E0001: A character that starts no token, such as
$ - E0002: A string literal that is not closed before the end of the file
- E0003: An invalid escape in a string: a backslash followed by anything but one of the escapes
- E0004: A
{or}in a sink literal such assql"...", which never interpolates - E0005: A
;: Oska has no semicolons, because a line break ends a statement - E0100: The parser expected an expression, a type, or a pattern and found something else
- E0101: The parser expected a specific token, such as a
), and found another - E0102: A
{...}hole in a string that holds more than a name or a field path, such as{n + 1} - E0103: A bare `{ .
- E0104: A
letorvarwithout an initializer - E0105: A chained comparison such as
a < b < c - E0106: An assignment whose left side is not a name or a field path, such as
x + 1 = 2 - E0107: A statement at module level, where only items are allowed
- E0110: An
ensuresclause without a|r|binding for the return value - E0111: A
selforvar selfreceiver that is not the first parameter - E0112:
varon a parameter other than theselfreceiver - E0113: A
whereclause - E0120: A missing comma between the declared fields of a struct or the variants of an enum
- E0130: A glob import such as
use std.sql.* - E0131: A renaming import such as
use std.sql.query as q - E0132: An attribute name outside the fixed set, which holds only
integration - E0133:
unsafe, which Oska does not have - E0140: An or-pattern such as
A | B - E0141: A range pattern such as
1..5 - E0142: An
@binding such asv @ Some(_) - E0143: A comma between
matcharms - E0150: A
selforvar selfreceiver on a function outside animplortraitblock - E0151:
pubon animplblock - E0160: A string pattern with an interpolation hole
- E0161: A test name with an interpolation hole
- E0162:
pubon a trait method - E0163:
pub test - E0164:
pub use - E0165:
#[integration]on an item other than atest - E0170:
#[capability]on an item other than astruct, in the prelude - E0200: Unknown type or trait name, or a qualified path such as
sql.Querywhose first segment is not a module bound by a plainuse - E0201: A trait where a type is expected (
x: Display), or a type where a trait is expected (T: Int) - E0202: 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 inherentimplblocks - E0210: A struct or enum whose own fields name a capability-bearing type (a built-in capability, a
captype, or acap fn, including inside written type arguments such asList<Stdout>) is not declaredcap - E0211: A
mainparameter whose type is not a built-in capability orArgs - E0212:
mainreturns something other than()orResult<(), E>(spans the return type), orEhas noimpl Display(spansE) - E0213: A type, enum variant, trait, or type parameter name that does not start with an uppercase letter (ADR 0005)
- E0214: A function, method, field, parameter, or local variable (
let,var,for) name that starts with an uppercase letter (ADR 0005) - E0215: A struct or enum with no base case: every way to build it contains itself, as in
struct Loop { me: Loop } - E0216: A call to
dbg(...)when checking with--release - E0217: A
mainparameter whose type is a directory or file capability:Dir,DirRead,DirWrite,FileRead, orFileWrite - E0218: A
requiresorensuresclause on a method ofimpl Trait for Type - E0219: A
requiresorensuresclause onmain - E0220: Type mismatch: an expression's type differs from the type expected there
- E0221: Unknown value name, or
selfoutside a method with a receiver - E0222: Integer literal out of range for its type, such as
300as aU8 - E0223: 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: Wrong number of arguments in a call or construction
- E0225: Argument label that does not match its parameter or field, or a label on a positional field
- E0226: Named field constructed without its label
- E0227: Unknown field, or a method used without calling it
- E0228: Unknown method, variant, or associated function, or an associated function called on a value
- E0229: Assignment to something that is not a
varbinding: aletbinding, a parameter, or a field ofselfin a method withoutvar self - E0230: Mutating method (
var self) called on something that is not avarbinding - E0231: Call of a value that is not a function
- E0232:
breakorcontinueoutside a loop - E0233: A type that inference cannot work out, such as
let xs = List.new()with no later use - E0234: A type name used as a value, or a type that cannot be constructed
- E0235:
forover a value that is not aListor a range - E0240: An expression statement whose
Resultvalue is dropped - E0241:
?on a value that is neither aResultnor anOption - E0242:
?on aResultwhose error type is not the enclosing function's error type, with noimpl Fromto convert it - E0243:
?in a function (or closure) that does not return the same kind: anOptionin a function returningResult(convert with.ok_or(err)?), aResultin one returningOption, or either in one returning neither - E0250: A pattern that names no variant or struct
- E0251: A constructor pattern with the wrong number of fields, such as
SomeorShape.Square(a, b) - E0252: A named field matched without its label (
Shape.Circle(r)) or with the wrong one, or a label on a positional field - E0253: A
matchthat is not exhaustive, checked with the pattern-usefulness algorithm through nested constructor patterns - E0254: An unreachable arm: the earlier unguarded arms already match every value it does, as with any arm after a
_or binding arm - E0260: A method called on a value of a generic parameter whose bounds provide no method of that name
- E0261: An
impl Trait for Typethat leaves out a required method (one without a default body) - E0262: An
implmethod whose signature differs from the trait's, onceSelfand the trait's arguments are replaced - E0263: An
impl Traitmethod that the trait does not declare - E0264: A method call that two or more of the receiver's traits (or a parameter's bounds) provide, when the type's own
impldoes not - E0265: A type that does not implement a trait it must:
==and!=needEq; a call must satisfy the callee's bounds; a qualified callTrait.method(x)needsx's type to implementTrait; an interpolation hole needsDisplay - E0270: A
cap fnused where a plainfnis expected: a closure that captures a capability-bearing value (a built-in capability, acaptype, acap fn, or a container of one, including a capability-bearingself), or acap fnvalue passed on - E0271: Construction of a prelude struct with private fields, such as a built-in capability (
Stdout(handle: 1)) orArgs - E0272: Reading a private field of a prelude type, such as
out.handle - E0273: A call of
read_to_string,list_dir,write, orcreate_dironFs,FsRead, orFsWrite, whether writtenread.read_to_string(path), qualified asFsRead.read_to_string(read, path), or taken as a value - E0274: 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
fnclosure captures, or a type holding aScopefor a parameter that an unscoped closure captures - E0280: A contract clause (
requiresorensures) calls a function that is not pure: one with a capability-bearing parameter or receiver, or acap fnvalue - E0281: A
requiresorensurescondition whose type is notBool - E0282: A
?or areturndirectly inside arequiresorensuresexpression, outside any closure - E0290: Two
impl Trait for Typethat overlap: some instantiation of each implements the same trait, with the same arguments, for the same type, as withimpl<T> Display for Box<T>andimpl Display for Box<Int> - E0291: An inherent
implfor a prelude type, such as `impl FsRead { . - E0292: A
Scopehandle that could outlive itsscopeblock:Scopein a function's or method's return type, in a struct or enum field's type, or in the type of ascopeblock's value, including inside wrappers such asOption<Scope>orList<Scope> - E0293: A call to
todo()when checking with--release - E0294: A
usewhose path does not start withstd.: only the standard library can be imported - E0295: A
use std.*of a module that does not exist - E0300: Untrusted text in a structural position: an
Untrusted<String>used where trustedStringis required, such as aStringparameter, field, or return type - E0310: A sink literal, such as
sql"...", whose module is not imported - E0311: A sink literal whose tag no
std.*module provides, such assqll"..." - E0312: A name that the module does not export, in a
usebrace group (use std.sql.{Query}) or a qualified path (sql.Query) - E0320:
Untrusted<T>whereTis not text, such asUntrusted<Int>,Untrusted<List<String>>, orUntrusted<T>for a genericT - E0340: A module's export written unqualified, such as
Dbafter a plainuse std.sql, which imports only the module - E0341: Text where a sink literal type is required, such as a
String, anUntrusted<String>, a string literal, or an interpolated string passed toDb.queryas query text - E0350: A
Secretinterpolated into a string, such as"Bearer {key}", or a value that holds one anywhere inside, such as aList<Secret<String>>, anOption<Secret<String>>, or a struct with aSecretfield - E0351: A
Secretcompared with==or!=, on either side - E0352: A
Secretused where it must beDisplay: aDisplaybound, or a call to.to_string() - E0360: A name declared by an imported
stdmodule but not exported by it, written unqualified - E0370:
maindeclares a capability that has no runtime yet:Net,NetConnect,NetListen,Spawn, orSched - E0371: The program imports a
stdmodule that has no runtime yet:std.procorstd.sql, used or not - E0380: 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
mainthat is neither a capability norArgs - P0001: Integer overflow: the result of
+,-,*,/, or unary-does not fit its type, as with aU80 - 1or anI8-128 / -1 - P0002: Index out of bounds:
List.atwas given an index below 0 or not below the list's length - P0003:
todo()reached - P0004: Division by zero: the right operand of
/or%is zero - P0005:
spawnon a finished scope: the handle'sscopeblock has ended, and work never runs outside a scope - P0006: Precondition violated: a
requiresclause of the function called is false, so the caller broke the contract - P0007: Postcondition violated: an
ensuresclause of the function that returned is false, so the function broke its promise - P0010:
t.assert(cond)was givenfalse - P0011:
t.assert_eq(actual, expected)was given two values that differ throughEq - P0012:
t.assert_ne(actual, other)was given two equal values - P0013:
t.fail(message)was called - P0020:
Env.secretasked for a variable the environment does not set - P0021: Calls nest too deep: runaway recursion
- P0035:
String.slicewas 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:
String.repeatwas given a negative count - P0037:
String.repeatwould build a text over 256 MiB, so the interpreter panics instead of running out of memory