-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Make @intFromEnum
an error for empty enums
#18795
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
Conversation
Empty Short version:
Using such a type somewhere asserts to the compiler that it will never be instantiated. EDIT: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes running @intFromEnum on undefined an error, which is something that has bitten me too many times.
It should return undefined
.
should we reconsider empty enums in general? they have no actual value representation, and so i'm confused why we have them.
See the issues I linked in my comment.
This PR makes one change which is objectively wrong (erroring on |
I hear the people, and undefined it shall return. However in response to @mlugg I disagree. This is a patch for the issue. I think that I should add a link and a TODO to it. see tagName for the exact same temporary fix. We should not keep a crash for an undefined (no pun) amount of time because of a non resolved issue. I feel the solution is very clear, but I understand it's under debate. (away for most of the day so no patch rn for return undefined) |
@intFromEnum
an error for undefined and empty enums@intFromEnum
an error for empty enums
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prevents the compiler from crashing and that's the best that can be done until the proper behavior is decided on.
fixes #18767
@intFromEnum
on undefined return undefined@intFromEnum
on empty enums (that are exhaustive) an error.should we reconsider empty enums in general? they have no actual value representation, and so i'm confused why we have them.