E1042: argument name does not fit the enum variant

View source

A variant declared with named fields, such as Circle { radius: u32, }, is built with named arguments that match those fields.

A variant declared with named fields, such as Circle { radius: u32, }, is built with named arguments that match those fields. A variant declared with positional fields takes positional arguments only. A name that the variant does not have, a name on a positional variant, or a missing name on a named variant are all rejected. For a positional argument given to a named variant the message says that the variant takes named fields. The error points at the argument.

Example

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

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

Fix

Use the field name that the variant declares.

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

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

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