-
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
Fix finding references to a type when there's a module with the same name #16081
Fix finding references to a type when there's a module with the same name #16081
Conversation
Ok, looks like it's not going to be that easy :) |
…odule-name-references
…:0101/fsharp into fix-same-type-and-module-name-references
The ProblemSo what's happening here is, when searching for modules we report what we find to the name resolution sink. Even when the identifier could still refer to a type with the same name. And from there it's written to fsharp/src/Compiler/Checking/NameResolution.fs Lines 3067 to 3071 in b0f2370
Attempt 1There is a comment there already suggesting that modules and types should be searched together. I tried that with the existing mechanisms - to continue the search even when we've found a module by that name. But that seems to be neither necessary nor fix the issue. Which is that once we call the sink with whatever we identified first, it stays there. Attempt 2Another thing I tried is to replace the module item with the type when we've found it by using fsharp/src/Compiler/Checking/NameResolution.fs Line 2281 in b0f2370
However that did have a bunch of side effects one of them being that type names got replaced by Attempt 3The alternative, which is what's currently in this PR, is to suppress calling the name resolution sink from here when we're searching for module names: fsharp/src/Compiler/Checking/NameResolution.fs Line 2435 in b0f2370
This fixes the problem and only has 2 side effects:
So I think this is a good trade off and it doesn't require any drastic changes. It is a bit ugly though. |
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.
Mhm yeah let's see if those are the only side effects :D
Yeah, I should probably clarify that those are the only side effects covered by our test suite :) |
Co-authored-by: Petr <psfinaki@users.noreply.github.com>
Fixes #14411
No questions allowed.