Uh oh!
There was an error while loading. Please reload this page.
Implement non-exhaustive enums - #4191
Conversation
* error for '_' prong on exhaustive enum * todo panic for `@tagName` on non-exhaustive enum * don't require '_' field on tagged unions
Uh oh!
There was an error while loading. Please reload this page.
andrewrk
left a comment
There was a problem hiding this comment.
Nice, this is substantial language progress.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| add_node_error(g, field_node, buf_sprintf("non-exhaustive enum must specify size")); | ||
| enum_type->data.enumeration.resolve_status = ResolveStatusInvalid; | ||
| } | ||
| if (field_count > 1 && log2_u64(field_count - 1) == enum_type->size_in_bits) { |
There was a problem hiding this comment.
Isn't this impossible to trigger for a non-extern enum? The enum tag size is chosen before the _ field is skipped.
Moreover the field_count is now invalid and enumeration.fields contains one entry too many.
There was a problem hiding this comment.
Tag size must be specified for non-exhaustive enums so it is possible to hit.
constE=enum(u2) {
a,
b,
c,
d,
_, // error: non-exhaustive enum specifies every value
};a3faf7c to
6c8f01dCompare
andrewrk
left a comment
There was a problem hiding this comment.
Nice work! I consider this to be mergeable right now, but I'll leave it up to you if you want to take the test case suggestion before I hit the button.
Uh oh!
There was an error while loading. Please reload this page.
Closes#2524
Any suggestions to improve the documentation are welcome.