Catching "invalid enum value" errors

BTW fix for this is planned on my TODO list for a long time (for now I just re-implement smaller subset of what I need from std.enums for non-exhaustive enums). If I understand correctly, this restriction was relevant when one type of enumerations were allowed to have field aliases (now-removed extern enums), and since we don’t have them anymore this restriction can be lifted.

Related:
Add some enum utilities by SpexGuy · Pull Request #8171 · ziglang/zig · GitHub (original PR that introduced std.enums, merged March 19, 2021)
enums should disallow multiple enumerations with the same value · Issue #2115 · ziglang/zig · GitHub (proposal to remove extern enums, April 28, 2021, also note about time complexity of std.enums.directEnumArray on a extern enum)

1 Like