-
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
Add a compiler warning for lowercase literals in patterns #666
Conversation
I like it, and it looks good from my review. |
@neoeinstein Thanks for reviewing. It's really useful. |
Very important warning. Great job! 👍 |
| Some x -> x | ||
| Some value -> | ||
let name = id.idText | ||
if not (String.IsNullOrEmpty name) && Char.IsLower(name.[0]) then |
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.
when would name
be empty?
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'm not sure it will happen. The check is there to make sure that the index access (name.[0]
) is totally safe.
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.
Ok me neither. However it does seem surprising that a identifier is the empty string.
This looks good to me. |
committed. |
@KevinRansom I think it's better to reference the PR number and the issue number (if there is one) in the commit message. As it is committed now, it's really hard to blame the original author for bugs in the original PR :-). |
I screwed up the commit, I just reverted and am going to attribute it properly. |
A quick look at the PR # explains everything! |
When I rebased, I forgot to set the author correctly. There are many times when I wished we just pressed the merge button. Once again sorry for the brain-fart. Now it's time for bed. Kevin |
Dude, you are the one that is merging. Just make that decision to use the merge button. ;-) |
@KevinRansom No worries. I don't mind at all. The main problem is traceability and maintainability that we have to be careful when merging PRs. |
@forki 👍 |
UserVoice request (approved for F# 4.x): http://fslang.uservoice.com/forums/245727-f-language/suggestions/6668206-warn-when-literal-attribute-is-used-with-lowercase
This is a small and low-risk change to warn users when lowercase literals are ignored in favor of variable binding patterns.
Unit tests have been added.