-
Notifications
You must be signed in to change notification settings - Fork 789
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
Improve Unclear error FS3204 Multicase union struct #14105
Improve Unclear error FS3204 Multicase union struct #14105
Conversation
…truct-then-all-fields-within-the-union-type-must-be-given-unique-names
…all-fields-within-the-union-type-must-be-given-unique-names' of https://github.com/edgarfgp/fsharp into union-type-has-more-than-one-case-and-is-a-struct-then-all-fields-within-the-union-type-must-be-given-unique-names
870c56d
to
56c28c0
Compare
56c28c0
to
77e1a72
Compare
There are some baseline tests failing. I will wait for feedback about this proposal before I update all :) |
tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/MultiCaseUnionStructTypes.fs
Show resolved
Hide resolved
tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/MultiCaseUnionStructTypes.fs
Show resolved
Hide resolved
tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/MultiCaseUnionStructTypes.fs
Show resolved
Hide resolved
Good to see this, thank you @edgarfgp . Added a few comments about scenarios where I would like to maintain backwards compat. with what was compiling until now. ( We do not have to be strict about code that has errors even before. But for working code, I would prefer not to introduce breaking changes unless we have to) |
…truct-then-all-fields-within-the-union-type-must-be-given-unique-names
…truct-then-all-fields-within-the-union-type-must-be-given-unique-names
…truct-then-all-fields-within-the-union-type-must-be-given-unique-names
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.
Great job, again
tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/MultiCaseUnionStructTypes.fs
Show resolved
Hide resolved
The error message was good before, but now it is not. In the new version, the fact that this is about FIELDs has disappeared. |
@T-Gro how about that? I wanted to remove the tautology in the previous version and ended up removing too much :D |
I think both are ok for me :) as new we are also using the field ranges . Let me know what is the final error message and I will update it |
I'm happy to see this being improved! |
…truct-then-all-fields-within-the-union-type-must-be-given-unique-names
…truct-then-all-fields-within-the-union-type-must-be-given-unique-names
@T-Gro Thanks for merging this :) |
Thank you!!! this is huge as the previous error lacked an example demonstrating what it means in this context to name the cases, and how to do it. |
Fixes #3648
Problem
Poposal
Update the error message to:
If a union type has more than one case and is a struct, then all fields within the union type must be given unique field names. For example: 'type A = B of b: int | C of c: int' (unique field names 'b' and 'c' assigned). based @T-Gro suggestion
Use the field range to report the error in all the fields that does not have a compiler autogenerated name "Item"
Update : Would be good to put his in a preview lang flag