ErrorsValues and types · rule
type.unknown_enum_variant
The code names a variant that the enum doesn't have, often a misspelling of one it does.
Area 2, Values and types; not declinable; the next step is usually the agent's.
Why Jadpo refuses it
An enum is a closed list of named alternatives, so every value it can hold is one of the variants it declares. A name that isn't among them can never be a value of the enum. Jadpo reports it when you check, and names the variant it is closest to when there is one.
What it looks like
main.jadpo:
type TicketStatus = Enum { open closed}function reopen() -> TicketStatus { return TicketStatus.opne}
error TicketStatus has no variant opne
--> main.jadpo:7:25
|7 | return TicketStatus.opne | ^^^^ not a variant
- reason
TicketStatus's variants areopenandclosed. Did you meanopen?- next
- Use
TicketStatus.open(agent) - rule
- type.
unknown_ enum_ variant - help
- https://jadpo.
dev/docs/errors/type. unknown_ enum_ variant
(agent) at the end of the next: line means your coding agent can make
the fix itself.
How to fix it
If you meant a variant the enum has, spell it as the enum declares it:
return TicketStatus.openreopen now returns the open variant.
If the enum needs another alternative, add it to the enum's list:
type TicketStatus = Enum { open reopened closed}function reopen() -> TicketStatus { return TicketStatus.reopened}
A match on TicketStatus must now cover reopened as well.
Related
Markdown for agents: /docs/errors/type.unknown_enum_variant.md.Built from Jadpo main at aee2e8f.