E1090: cast between types that are not both integers

View source

value as Type is a checked conversion between integer types (ADR-0042).

value as Type is a checked conversion between integer types (ADR-0042). It does not turn a Bool into a number, a number into a Bool or a float, or a struct into anything. Each of these changes the meaning of a value, and Actus asks for that to be written out. The message names the source and the target type. The error points at the cast.

Example

actus
verb main() {
    erg flag: Bool = true;
    erg n = flag as u8;
}
actus
verb main() {
    erg n: Int = 1;
    erg flag = n as Bool;
}

Fix

Write the conversion that the program means, with a condition or a comparison, and keep as for integers.

actus
verb main() {
    erg flag: Bool = true;
    erg n: u8 = if flag { 1u8 } else { 0u8 };
}
actus
verb main() {
    erg n: Int = 1;
    erg flag: Bool = n != 0;
}

Run actus explain E1090 in your terminal to read this entry offline. Browse Ownership & types or all error codes.