Lyricdev
GitHub

LYR-RT0009

a conversion to char of no Unicode scalar value

panic ยท spec 03-types

An integer converted with as char is a surrogate (0xD800 to 0xDFFF) or beyond 0x10FFFF. Check the value before converting it.

Program

fn toChar(x: uint32): char {
    return x as char;
}

fn main(): void {
    assert(toChar(0xD800) != 'a');
}