-
Notifications
You must be signed in to change notification settings - Fork 13.3k
enum expects determinant to be isize #21493
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
My understanding of what is happening in this example is that when zero is passed as Thus, the discriminant In conclusion, the error message could be improved and I don't understand why if no explicit size for the enum is given, an |
/cc @rust-lang/lang I think the reason here is that integer falllback constraints works for the literal, so I'm not sure this is actually a bug.
This now gives an error
|
As far as I can see there is no bug here - if you don't specify the type, we infer the right one, if you specify the wrong type, there is a type error. Sounds like we even give a nicer error now. The only question is should we infer the discriminant type from the literal types, and that sounds like a bad idea to me. Suggest this can be closed. |
So I think it makes sense that the integer value used for the discriminant must have SOME type. We seem to have selected I don't think we can (or should) use the domain of values to pick the required type, since there is kind of a chicken and egg problem. (We have to type the expressions in order to evaluate them, particularly because of overflow semantics, but we can't type them until we know the answers.) Also: the error message for using a So I guess my feeling is "not a bug". |
Three of us in a row with "not a bug", so I'll close. @dcampbell24 , it's been a long time since you opened this, but let me know if you disagree. |
The text was updated successfully, but these errors were encountered: