Lyricdev
GitHub

LYR-SEM0006

a conversion that does not exist

error ยท spec 03-types

An as between types it does not convert (it converts numbers only, and char to and from uint32), or an f-string hole whose value has no Display conformance or carries a format specifier Display does not take.

Explanation

as converts between the numeric types, and between char and uint32 (its scalar value). A bool is not a number, and every other conversion is a method: T.from(v) or v.into() through a From conformance. An f-string renders a hole through Display; an optional or a type without the conformance does not render.

Use the conversion the types provide, write the test out (if (b) 1 else 0), or give the type :: [Display] with fn show(): string.

Wrong

fn main(): void {
    let b = true;
    let _ = b as int;
}
fn main(): void {
    let b = true;
    let _ = if (b) 1 else 0;
}