-
Notifications
You must be signed in to change notification settings - Fork 832
Allow arithmetic in enum definitions #14464
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
|
Can you please add a test for the diagnostics just like in the screenshot? |
|
The () will be required only in the enum case, right? |
Sure, otherwise everything would be broken :). I've only swapped enum case constants for expressions in the parser. |
|
All good now, I think. |
|
I could also take this as an opportunity to adjust error ranges if you want. https://sharplab.io/#v2:DYLgZgzgNAJiDUAfALgTwA4FMAEBBbAvALABQ252i2AGodgIwAypFl2AmnQExA== should only highlight the expression range. |
Agree, it makes more sense to use the expression's range only. |
|
Bump |
Expanding on #14370 and fsharp/fslang-suggestions#539.
One minor problem are error messages. Consider cases with inconsistent types:In the latter case,TcExprseems to insert type casts of some sort (I think), which preventEvalLiteralExprOrAttribArgfrom evaluating the expression, so type checking fails before enum case type consistency could be checked and we don't get the nice message in the first picture. I could useTcExprOfUnknownType, but I don't know how to "bind" the returned type to the type variablefieldTy.Sorted
Also, the parentheses are required, but I think that's fine.