-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Proposal: Non-exhaustive tagged unions #8162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
For what it's worth, I have a real world use-case for this in zig-wayland. The only alternative I see is making basically everything in the API generic over the version, which seems very heavy handed. |
How would this work? Are unnamed values implicitly |
It isn't meant to be ABI forwards-compatible like non-exhaustive enums. I don't think it should be possible to create an unnamed/invalid value, so actually hitting the switch (x) {
.a => |a| {},
.b => |b| {},
_,
} |
This feature has been implemented in #8163, which can be quickly updated if this is accepted. |
Currently, tagged unions with a non-exhaustive enum tag don't have the forwards-compatibility features in switches, because it's impossible to create a non-existent union value.
From the non-exhaustive enums proposal:
Non-exhaustive tagged unions can be useful in pure Zig APIs where new variants can be added, but breaking user code on updates is undesirable.
The text was updated successfully, but these errors were encountered: