tripon[github]

diagnostic codes / Types

E0202 type-mismatch

Two types are not the same type.

E0202type-mismatchtypes must match exactly; no implicit conversion exists; use cast<T>(x)
severityerror
bandTypes
in the v0 bootstrapemitted
explainralt explain E0202

Tripon has no implicit conversion, in either direction, including widening. Every place that asks two types to meet — a binding and its initializer, two operands, an argument and its parameter, a condition and `bool`, a return and its signature — requires them to be identical. The message names both sides and the value is left untyped so later errors do not cascade from it.

What it looks like

e0202.tp
use tier core;

fn main() -> i32 {
    print_f64(3);
    return 0;
}
ralt check e0202.tp
e0202.tp:4:15: error: builtin 'print_f64' expects f64, got i32
  [E0202 type-mismatch] types must match exactly; no implicit conversion exists; use cast<T>(x)

The integer literal `3` is an `i32` because that is the default for an integer literal. `print_f64` takes `f64`. The repair is a written conversion: `print_f64(cast<f64>(3))`.

What to do

  • Convert explicitly with `cast<T>(x)` on the side that needs to change.
  • If the types are integers of different widths, cast at the boundary where the width matters, not in the middle of an expression.
  • For a condition, the expression must already be `bool`; there is no truthiness and no `cast<bool>`.
  • For a struct initializer, all fields are required: `missing field 'y' in struct init` is this code.

Why the code exists

The rule is the same one that makes `i8` and `i64` separate types: an implicit conversion turns a width bug into a silent truncation that shows up in a value far from the source line. Making it a compile error moves it to the line that caused it.

What ralt explain says

ralt explain E0202
E0202
severity: error
name: type-mismatch
hint: types must match exactly; no implicit conversion exists; use cast<T>(x)

Related