-
Notifications
You must be signed in to change notification settings - Fork 790
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
Error when property has same name as DU case #16760
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8241e06
Error when property has same name as DU case
edgarfgp 23df1d9
Merge branch 'main' into fix-16646
edgarfgp dee4477
Update tests
edgarfgp af51309
Merge branch 'fix-16646' of github.com:edgarfgp/fsharp into fix-16646
edgarfgp eb97c47
fix test
edgarfgp 0916405
Merge branch 'main' into fix-16646
edgarfgp 8074f51
Merge branch 'main' into fix-16646
edgarfgp 65a4834
fix test
edgarfgp ca6a6cc
Merge branch 'fix-16646' of github.com:edgarfgp/fsharp into fix-16646
edgarfgp 0d79645
update condition
edgarfgp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@psfinaki This now raises an error message if you accessing to a member that has the same name as the union case. reusing
FS0023
(Error 23, Line 17, Col 51, Line 17, Col 56, "The member 'IdA' can not be defined because the name 'IdA' clashes with the union case 'IdA' in this type or module")
I propose we update the error message so it can be used in both cases ie
member
is definedmember
is usedAvoiding having to create another error number and message. Maybe
The member 'IdA' can not be used because 'IdA' clashes with the union case 'IdA' in this type or module
The name 'IdA' can not be used because 'IdA' clashes with the union case 'IdA' in this type or module
The member 'IdA' can not be defined or accessed because the name 'IdA' clashes with the union case 'IdA' in this type or module
cc @vzarytovskii
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.
Hmm but why not having both errors here? As in,
...would produce both
FS0023 The member 'IdA' can not be defined because the name 'IdA' clashes with the union case 'IdA' in this type or module
andFS0812 The syntax 'expr.id' may only be used with record labels, properties and fields
,as if they were independent (which they kind of are)?
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.
The issue is that the existing logic uses
error(Error(..))
which prevents the analysis to continue so even if we try to add both they would cancel each other. Ideally it would be good to change to useerrorR
but will require rewriting of pat of the analysis. The best we can do for now is to reuseFS0023
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.
I mean I probably misunderstand something here - why cannot/shouldn't we fix the error recovery in this case instead?
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.
It is not that we can't. But it will required updating/splitting the upstream analysis to make it work as
error
returnsexn -> 'T
anderrorR
returnsexn -> unit
.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.
But if you feel adventurous we can maybe pair on this, maybe in an AmplifyingF# session :)
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.
Context: This is the relevant piece of code that will needs updating https://github.com/dotnet/fsharp/blob/f29ce0aef9b70bfef03ef7466ec823e449bb864b/src/Compiler/Checking/CheckExpressions.fs#L9270C5-L9270C21
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.
Well I just believe this can be an opportunity to fix the underlying issue rather than patch the symptome. But that's just my opinion 👀
Otherwise, "The member 'IdA' can not be defined or accessed" is something I would pick out of the options.
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.
Well at the very least I would give a try and report some progress :)
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.
@psfinaki Im revisiting this here #17088