E1033: field value has the wrong type

View source

The value given to a struct field, in a literal or in an assignment, must have the type that the field declares.

The value given to a struct field, in a literal or in an assignment, must have the type that the field declares. The message names the field, the struct and both types. The error points at the value. An unsuffixed integer literal takes the type of the field, so a: 200 is a u8 for a u8 field (ADR-0119); a literal with a suffix of another type, or an Int variable, is still rejected.

Example

actus
struct Point {
    x: Int,
}

verb main() {
    erg p: Point = Point { x: true, };
}

Fix

Give the field a value of its type, or change the type of the field.

actus
struct Point {
    x: Int,
}

verb main() {
    erg p: Point = Point { x: 1, };
}

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