Lyricdev
GitHub

LYR-SEM0001

a value of another type than the place takes

error ยท spec 03-types

An expression's type does not fit where it stands: an initializer, an argument, a return value, an assignment.

Explanation

A place with a declared type takes values of that type and of the types that convert to it implicitly. Lyric widens little on its own: an int is no float, a uint is no int, an optional is no value of its inner type, and nothing becomes an interface it does not conform to.

Write a value of the declared type, convert it explicitly (as between numbers, a From/Into method otherwise), or change the declaration.

Wrong

fn main(): void {
    let x: int = "text";
    let _ = x;
}
fn main(): void {
    let x: int = 5;
    let _ = x;
}