E1043: enum variant value has the wrong type

View source

The value for a payload field must have the field's declared type.

The value for a payload field must have the field's declared type. Actus has no implicit conversion. The message names the variant, the field, and both types. A positional field is named by its position, so the first field is 0. The error points at the value. An unsuffixed integer literal takes the type of the payload field, so Shape.Circle(radius: 5) is accepted for a u32 field (ADR-0119); a literal with a suffix of another type is rejected.

Example

actus
enum Shape {
    Circle { radius: u32, },
}

verb main() {
    erg s: Shape = Shape.Circle(radius: true);
}

Fix

Give the field a value of its type.

actus
enum Shape {
    Circle { radius: u32, },
}

verb main() {
    erg s: Shape = Shape.Circle(radius: 1u32);
}

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