E0007 — Type mismatch

An expression’s type doesn’t match what the context expects.


What triggers it

The typechecker walks each expression and compares its type against the declared or inferred requirement at the use site. Mismatches — let x: int = "hi";, passing a Bool where a function wants an Int, storing a Float in an Int local — all surface here.

Minimal example

fn main() {
    let x: int = "hi";
    return 0;
}

Output:

scratch.rs:2:18: error[E0007]: type mismatch: expected `int`, got `String`
   let x: int = "hi";
                ^^^^

Fix

Change one side to match the other. If you meant to parse / convert, call the matching builtin (to_int, to_float, etc.).

fn main() {
    let x: int = 42;
    return 0;
}

Source

Emitted from the typechecker in resilient/src/typechecker.rs.