-
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
Warn on uppercase identifiers in patterns. #15816
Conversation
...pqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/UppercaseIdentifier04.fs
Outdated
Show resolved
Hide resolved
I am, honestly, not sure if it's a good idea. A rule of thumb is - if this will suddently introduce new warnings in existing codebases, it should go under separate version flag or introduce a separate warning, which will be opt-in. In this particular case - the use cases are country and language codes, which are very common in codebases, and it's not an opt-in warning. I personally thing we should keep it, or make it an additional warning, which will be opt-in. |
I was reading the F# spec and I did not find anything about the check >=3. It only stated the following. I think the main for me is that we only get this warning named pattern that is Uppercase and the length is >= 3 which seems confusing to me. my wishful thinking will expect:
Update: Now that I know about this. I cannot unsee this:). Maybe @dsyme can give us some historical context. |
@vzarytovskii Yeah I will definitely add a lang version flag. I wanted to first understand what were the implications of this check |
I'm still not convinced that language flag is a proper way of doing that. It will cause a lot of new warnings in existing codebases when updating to new language version. And only two options will be either to downgrade a language version, or disable the warning. I think it will instead be a great use case for analyzers sdk. |
Yeah I understand, this check seems to be a terrible hack and dealing with this using an analyser seems a more a bandage. But yeah Happy to close this PR at the very least now I understand the reason of this unexpected compiler behaviour 😓 |
Well, we have a huge codebase but in the end the amount of code to be fixed was, well, graspable. Also, the original error was for missing the full qualification of DU, which is probably not that common, also judging by the activity in that bug. Those are just some thoughts, I am sort of on a fence with that. Although at least the collateral changes in this PR are worth merging. |
@vzarytovskii @psfinaki Based on the provided feedback, I have reverted to using the original check and:
I think this will, at the very least give more context about this confusing behaviour. |
Closing this as there does not seem to be a consensus as to how to better deal with this. Feel free to reopen in case you want to take some of the changes in this PR |
❗ Release notes required
|
In the spirit of making some progress here. I have reverted the breaking changes as I understand that there is not way to have a proper fix for this as it will break people's code or will produce unnecessary noise. Beforematch 1 with
| US -> "US" // No Warning
| UK -> "UK" // No Warning
| U -> "U" // No Warning Aftermatch 1 with
| US -> "US" // Warning
^^
| UK -> "UK" // Warning
^^
| U -> "U" // Warning
^
For more info check the tests. |
I'm personally fine with it, so I'll throw @T-Gro and @KevinRansom under the bus to make the decision. |
I guess I will have to wait for the bus to arrive to my station for sometime :) |
...pqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/UppercaseIdentifier04.fs
Outdated
Show resolved
Hide resolved
Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com>
0ea281f
to
3adf463
Compare
@vzarytovskii This is ready. |
Fixes #6712, #17878
Don't warn on uppercase identifiers in binding patterns . Removing the historical
hack
when it was only raise if the identifier was >= 3.Before
After
Note: We will only raise a warning in the context of
True
match case clause.Checklist