Skip to content

Error Index

Every Kōdo compiler error has a unique code for easy reference and machine consumption.

RangePhaseDescription
E0001–E0099LexerTokenization errors
E0100–E0199ParserSyntax errors
E0200–E0299TypesType checking errors
E0300–E0399ContractsContract verification errors
E0400–E0499ResolverIntent resolution errors
E0500–E0599MIRMid-level IR errors
E0600–E0699CodegenCode generation errors
E0700–E0799TestingTest framework errors
E0800–E0899StdlibStandard library errors
W0001–W0999WarningsCompiler warnings

An unrecognized character was found in the source code.

error[E0001]: unexpected character `@`
--> src/main.ko:3:15
|
3 | let x = 42 @ 3
| ^ unexpected character

A string literal was opened but never closed.

error[E0002]: unterminated string literal
--> src/main.ko:5:10
|
5 | let s = "hello
| ^ string literal starts here but is never closed

A token was found where a different one was expected.

Every .ko file must start with a module declaration.

Modules must include a meta block (enforced in semantic analysis).

The file ended before a complete construct was parsed.

A requires or ensures block contains a malformed expression. The parser recovers by skipping to the closing } and continues parsing the function body, allowing the compiler to report additional errors in the same file rather than halting at the first malformed contract.

Two types were expected to match but don’t.

A type name was used that doesn’t exist in scope.

A function was called with the wrong number of arguments.

A value was called as a function but its type is not a function type.

A for loop range bound is not of type Int. Both start and end must be Int.

error[E0204]: type mismatch: expected `Int`, found `Bool`
--> src/main.ko:5:18
|
5 | for i in true..10 {
| ^^^^ expected `Int`, found `Bool`

Both operands of a range expression (.. or ..=) must be of the same numeric type.

The module does not contain a meta block. All modules must be self-describing.

The purpose field in the meta block is an empty string.

The meta block does not contain a purpose field.

A struct type was referenced but has not been defined in the current module or any imported module.

error[E0213]: unknown struct `Point` at 5:20
--> src/main.ko:5:20
|
5 | let p: Point = Point { x: 1, y: 2 }
| ^^^^^ struct not defined

A required field is missing from a struct literal.

error[E0214]: missing field `y` in struct `Point` at 5:20
--> src/main.ko:5:20
|
5 | let p: Point = Point { x: 1 }
| ^^^^^^^^^^^^^^ missing field `y`

An unknown field was provided in a struct literal.

error[E0215]: unknown field `z` in struct `Point` at 5:20
--> src/main.ko:5:20
|
5 | let p: Point = Point { x: 1, y: 2, z: 3 }
| ^ unknown field

A field was specified more than once in a struct literal.

error[E0216]: duplicate field `x` in struct `Point` at 5:20
--> src/main.ko:5:20
|
5 | let p: Point = Point { x: 1, x: 2 }
| ^ duplicate field

A field access was attempted on a non-existent field.

error[E0217]: no field `z` on type `Point` at 6:20
--> src/main.ko:6:20
|
6 | let val: Int = p.z
| ^ field does not exist

An enum type was referenced but has not been defined.

error[E0218]: unknown enum `Color` at 5:20
--> src/main.ko:5:20
|
5 | let c: Color = Color::Red
| ^^^^^ enum not defined

A variant was referenced that does not exist in the enum.

error[E0219]: unknown variant `Purple` in enum `Color` at 5:20
--> src/main.ko:5:20
|
5 | let c: Color = Color::Purple
| ^^^^^^^ variant does not exist

A match expression does not cover all variants of an enum.

error[E0220]: non-exhaustive match on `Color`: missing variants ["Blue"] at 6:5
--> src/main.ko:6:5
|
6 | match c {
| ^^^^^ add missing arm: `Color::Blue => { ... }`

A generic type was instantiated with the wrong number of type arguments.

A type parameter was referenced but not defined.

error[E0222]: undefined type parameter `U` at 5:30
--> src/main.ko:5:30
|
5 | fn identity<T>(x: U) -> T {
| ^ type parameter `U` not in scope

A generic type was used without providing required type arguments.

The try operator ? was used in a function that does not return Result.

error[E0224]: operator `?` can only be used in functions returning Result at 6:25
--> src/main.ko:6:25
|
6 | let val: Int = risky()?
| ^ function must return Result to use `?`

Optional chaining ?. was used on a non-Option type.

error[E0225]: optional chaining `?.` requires Option type, found `Int` at 6:20
--> src/main.ko:6:20
|
6 | let val: Int = x?.value
| ^^ `x` is `Int`, not `Option<T>`

Null coalescing ?? was used on a non-Option type.

error[E0226]: null coalescing type mismatch: left must be Option, found `Int` at 6:20
--> src/main.ko:6:20
|
6 | let val: Int = x ?? 0
| ^ left side must be `Option<T>`

E0227: Closure Parameter Missing Type Annotation

Section titled “E0227: Closure Parameter Missing Type Annotation”

A closure parameter is missing its type annotation. In Kōdo v1, all closure parameters must have explicit type annotations.

error[E0227]: closure parameter `x` is missing a type annotation
--> src/main.ko:5:20
|
5 | let f = |x| { x + 1 }
| ^ add a type annotation: `x: Int`
|
= help: Kōdo v1 requires explicit types on closure parameters

An .await expression was used outside of an async fn. The .await syntax is only valid inside async functions.

error[E0250]: `.await` can only be used inside an `async fn`
--> src/main.ko:5:30
|
5 | let val: Int = compute().await
| ^^^^^ move this expression into an `async fn`

A spawn block captures a mutable reference, which is not allowed in structured concurrency (reserved for future use).

An actor’s field was accessed directly from outside a handler. Actor fields are private to handler methods.

error[E0252]: cannot access actor field `count` directly on `Counter`
--> src/main.ko:10:20
|
10 | let x = counter.count
| ^^^^^ use a handler method to access `count` instead

A trait was referenced but has not been defined.

error[E0230]: unknown trait `Printable` at 5:10
--> src/main.ko:5:10
|
5 | impl Printable for Point {
| ^^^^^^^^^ trait not defined

A required method from a trait is missing in an impl block.

error[E0231]: missing trait method `to_string` for trait `Printable` at 5:1
--> src/main.ko:5:1
|
5 | impl Printable for Point {
| ^^^^^^^^^^^^^^^^^^^^^^^^ add missing method: `fn to_string(self) -> String`

A concrete type does not satisfy a trait bound required by a generic parameter. This implements bounded quantification (System F<:) — when a generic parameter declares trait bounds like T: Ord + Display, any concrete type argument must implement all specified traits.

error[E0232]: type `Int` does not implement trait `Hashable` required by generic parameter `T` at 10:12
--> src/main.ko:10:12
|
10 | lookup(42)
| ^^ type `Int` does not implement trait `Hashable`
|
= help: implement trait `Hashable` for type `Int`, or use a type that already implements it

An impl block for a trait is missing a required associated type binding. Every associated type declared in the trait must be bound to a concrete type via type Name = ConcreteType in the impl block.

error[E0233]: missing associated type `Item` for trait `Iterator` at 8:1
--> src/main.ko:8:1
|
8 | impl Iterator for MyList {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ missing `type Item = ...`
|
= help: add `type Item = <concrete type>` inside the impl block

An impl block provides a type binding for a name that is not declared as an associated type in the trait.

error[E0234]: unexpected associated type `Output` for trait `Iterator` at 8:1
--> src/main.ko:8:1
|
8 | impl Iterator for MyList {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ `Output` is not an associated type of `Iterator`
|
= help: remove the `type Output = ...` binding, or check the trait definition

A method was called on a type that does not have it.

error[E0235]: no method `length` on type `Int` at 6:20
--> src/main.ko:6:20
|
6 | let n: Int = x.length()
| ^^^^^^ method does not exist on `Int`

A variable was used after its ownership was transferred (moved). Once a value is moved, it cannot be accessed.

error[E0240]: variable `x` was moved at line 5 and cannot be used here
--> src/main.ko:6:15
|
6 | println(x)
| ^ use `ref` to borrow instead of moving

A borrowed reference cannot escape the scope that created it.

A value cannot be moved while it is currently borrowed by another variable.

A break statement was used outside of a while, for, or for-in loop.

error[E0243]: `break` outside of loop
--> src/main.ko:5:5
|
5 | break
| ^^^^^ `break` can only be used inside `while`, `for`, or `for-in` loops

A continue statement was used outside of a while, for, or for-in loop.

error[E0244]: `continue` outside of loop
--> src/main.ko:5:5
|
5 | continue
| ^^^^^^^^ `continue` can only be used inside `while`, `for`, or `for-in` loops

A mutable borrow (mut) was attempted on a variable that already has an active immutable borrow (ref). A mut borrow is exclusive and cannot coexist with any other borrow.

error[E0245]: cannot borrow `x` as mutable while it is immutably borrowed
--> src/main.ko:6:20
|
6 | two_args(ref x, mut x)
| ^^^^^ `x` is already borrowed as `ref`

An immutable borrow (ref) was attempted on a variable that already has an active mutable borrow (mut). A mut borrow is exclusive.

error[E0246]: cannot borrow `x` as `ref` while it is mutably borrowed
--> src/main.ko:6:25
|
6 | two_args(mut x, ref x)
| ^^^^^ `x` is already borrowed as `mut`

A variable was mutably borrowed (mut) twice simultaneously. Only one mut borrow is allowed at a time.

error[E0247]: cannot borrow `x` as mutable more than once
--> src/main.ko:6:25
|
6 | two_args(mut x, mut x)
| ^^^^^ `x` is already borrowed as `mut`

An assignment was attempted on a variable that is immutably borrowed (ref). Immutable borrows do not allow mutation.

error[E0248]: cannot assign to `x` because it is borrowed as `ref`
--> src/main.ko:6:5
|
6 | x = 42
| ^^^^^^ `x` is an immutable reference

A tuple index exceeds the number of elements in the tuple type.

error[E0253]: tuple index 3 is out of bounds for tuple of length 2
--> src/main.ko:6:20
|
6 | let x = pair.3
| ^ tuple has 2 elements, valid indices are 0..1

A private function or type from another module was accessed. Only pub items can be used across module boundaries.

error[E0270]: `secret` is private to module `utils` and cannot be accessed from here
--> src/main.ko:8:15
|
8 | let x = secret()
| ^^^^^^ `secret` is private to module `utils`
|
= help: add `pub` to the declaration: `pub fn secret(...)`

A spawn block captures a variable with a borrowed reference (ref), which cannot be safely sent to another thread. Only owned values can cross thread boundaries.

error[E0280]: type `ref Int` cannot be sent between threads
--> src/main.ko:8:20
|
8 | spawn {
| ^ variable `x` of type `ref Int` is captured but is not Send
|
= help: use owned values (own) instead of references when sending data to spawned tasks

A function annotated with @confidence(X) where X < 0.8 is missing a @reviewed_by(human: "...") annotation. Agent-generated code with low confidence must be reviewed by a human.

error[E0260]: function `risky_fn` has @confidence(0.5) < 0.8 and is missing `@reviewed_by(human: "...")`
--> src/main.ko:5:1
|
5 | fn risky_fn() {
| ^^^^^^^^^^^^^^ add `@reviewed_by(human: "reviewer_name")` to function `risky_fn`

The computed confidence of a function is below the min_confidence threshold declared in the module’s meta block. Confidence propagates transitively through the call chain.

error[E0261]: module confidence 0.50 is below threshold 0.90. Weakest link: fn `weak_link` at @confidence(0.50)
--> src/main.ko:10:1
|
10 | fn main() -> Int {
| ^^^^^^^^^^^^^^^^ increase confidence of `weak_link` or lower `min_confidence`

E0262: Security-Sensitive Without Contract

Section titled “E0262: Security-Sensitive Without Contract”

A function marked @security_sensitive has no requires or ensures clauses. Security-sensitive code must have formal contracts documenting and enforcing security invariants.

error[E0262]: function `process_input` is marked `@security_sensitive` but has no `requires` or `ensures` contracts
--> src/main.ko:8:1
|
8 | fn process_input(data: String) -> String {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ add `requires { ... }` or `ensures { ... }` to function `process_input`

A closure captures a variable that has already been moved. Once a variable is moved (e.g., into another closure or by assignment), it cannot be captured again.

error[E0281]: variable `data` was moved and cannot be captured by this closure
--> src/main.ko:12:15
|
12 | let f2 = |x: Int| -> Int { println(data); x }
| ^^^^^^^^^^^^^^^^ `data` was moved at line 8; consider cloning the value before the first move

A closure captures a non-Copy variable by move, making it unavailable in the enclosing scope for subsequent use.

error[E0282]: closure captures `data` by move, making it unavailable after this point
--> src/main.ko:10:5
|
10 | let result = data + " world"
| ^^^^ `data` was moved into closure at line 8; consider cloning before capture

Two closures in the same scope both attempt to capture the same non-Copy variable by move.

error[E0283]: variable `data` cannot be captured by two closures
--> src/main.ko:12:15
|
12 | let f2 = |x: Int| -> Int { println(data); x }
| ^^^^^^^^^^^^^^^^ `data` already captured by closure at line 8; clone the value for each closure

A trust policy violation was detected. This occurs when module-level constraints are not met.

A requires clause cannot be statically proven.

An ensures clause cannot be statically proven.

A contract is provably violated by the implementation.

The Z3 SMT solver found a counter-example disproving the contract. This occurs when using --contracts=static or --contracts=both.

error[E0303]: contract refuted at 10..16: counter-example: b -> 0
--> src/main.ko:3:9
|
3 | requires { b != 0 }
| ^^^^^^^^^^ Z3 found counter-example: b = 0

A module invariant condition does not evaluate to Bool. Invariant conditions must be boolean expressions.

error[E0310]: invariant condition must be `Bool`, found `Int` at 42..50
--> src/main.ko:4:5
|
4 | invariant { 42 }
| ^^ expected Bool, found Int

No resolver strategy matches the declared intent.

The resolved implementation doesn’t satisfy the intent’s contracts.

An unrecognized key was used in an intent block.

A configuration value in an intent block has the wrong type. For example, passing a string where an integer is expected.

error[E0403]: intent config type mismatch: expected Int for key `count`, found String
--> src/main.ko:5:12
|
5 | count: "three"
| ^^^^^^^ expected Int

An indirect (function pointer) call failed during code generation. This typically occurs when referencing an unknown function.

error[E0600]: indirect call failure: function reference to unknown function `missing_fn`
--> src/main.ko:8:20
|
8 | let result = f(42)
| ^^ could not resolve function pointer

A test assertion failed at runtime. This indicates the tested code did not produce the expected result.

error[E0700]: assertion failed in test "add returns correct sum"
--> src/math.ko:12:9
|
12 | assert_eq(add(2, 3), 6)
| ^^^^^^^^^^^^^^^^^^^^^^^^ left: 5, right: 6

The left and right operands of assert_eq or assert_ne have different types. Both sides must be the same type.

error[E0701]: assert_eq type mismatch: left is `Int`, right is `String`
--> src/math.ko:10:9
|
10 | assert_eq(42, "42")
| ^^ ^^^^ right operand is `String`
| |
| left operand is `Int`
|
= help: convert one side so both operands have the same type

The type used in assert_eq or assert_ne does not support equality comparison. Only Int, String, Bool, and Float64 are supported.

error[E0702]: assert_eq does not support type `List<Int>`
--> src/math.ko:10:9
|
10 | assert_eq(my_list, other_list)
| ^^^^^^^ type `List<Int>` cannot be compared
|
= help: supported types are: Int, String, Bool, Float64

Two or more test blocks in the same module have the same name. Test names must be unique within a module.

error[E0703]: duplicate test name "basic addition" in module `math`
--> src/math.ko:15:5
|
8 | test "basic addition" {
| ---------------- first defined here
|
15 | test "basic addition" {
| ^^^^^^^^^^^^^^^^ duplicate test name

The test name must be a string literal, not a variable or expression.

error[E0704]: test name must be a string literal
--> src/math.ko:10:10
|
10 | test name {
| ^^^^ expected a string literal, e.g., test "my test" { ... }

All errors can be emitted as JSON with --json-errors:

{
"code": "E0200",
"severity": "error",
"message": "type mismatch: expected `Int`, found `String`",
"span": {
"file": "src/main.ko",
"line": 10,
"column": 5,
"length": 12
},
"suggestion": "convert the String to Int using `Int.parse(value)`",
"fix_patch": {
"description": "wrap value in Int.parse()",
"start_offset": 120,
"end_offset": 132,
"replacement": "Int.parse(value)"
},
"repair_plan": [
{
"description": "wrap value in Result::Ok()",
"patches": [{ "start_offset": 120, "end_offset": 132, "replacement": "Result::Ok(value)" }]
}
],
"spec_reference": "§3.1 Type System"
}

The fix_patch field contains a single machine-applicable patch. For complex errors requiring multiple steps, repair_plan provides a sequence of named steps that agents should apply in order. Both fields are optional and omitted when not applicable.