E1063: condition is not a Bool

View source

A case guard and an if condition decide which way the program goes, so they must have type Bool.

A case guard and an if condition decide which way the program goes, so they must have type Bool. Actus has no truthy or falsy values, and an integer is not a condition. ADR-0016 sets this rule for guards and ADR-0049 sets it for if. The message says whether it is a guard or an if and names the type that was found. The error points at the guard or at the condition.

Example

actus
verb main() {
    erg n: Int = 1;
    if n {
        println(int: n);
    }
}
actus
enum Shape {
    Circle(Int),
    Dot,
}

verb area(abs s: Shape) -> Int {
    return case s {
        Shape.Circle(r) if r => 1,
        Shape.Circle(r) => 2,
        Shape.Dot => 3,
    };
}

verb main() {
}

Fix

Compare the value to get a Bool.

actus
verb main() {
    erg n: Int = 1;
    if n != 0 {
        println(int: n);
    }
}
actus
enum Shape {
    Circle(Int),
    Dot,
}

verb area(abs s: Shape) -> Int {
    return case s {
        Shape.Circle(r) if r > 0 => 1,
        Shape.Circle(r) => 2,
        Shape.Dot => 3,
    };
}

verb main() {
}

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