E1040: unknown enum variant

View source

An enum has a closed set of variants.

An enum has a closed set of variants. A constructor such as Color.Green or a pattern in a case names a variant that the enum does not declare. The message names the variant and the enum, and the error points at the name. In a case, a misspelt variant is reported here, not as a missing variant.

Example

actus
enum Color {
    Red,
    Blue,
}

verb main() {
    erg c: Color = Color.Green;
}

Fix

Use a variant that the enum declares, or add the variant to the enum.

actus check --format json offers this as a fix: rename the variant to the one declared variant whose name is close (a safe fix); nothing is offered when two variants are equally close.

actus
enum Color {
    Red,
    Blue,
}

verb main() {
    erg c: Color = Color.Blue;
}

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