This compiler like:
let test Xf Yf = Xf + Yf
This compiler no like:
let test Xfd Yfd = Xfd + Yfd
Warning:
Uppercase variable identifiers should not generally be used in patterns, and may indicate a misspelt pattern name.
Maybe I’m not googling properly, but I haven’t managed to track down anything which explains why this is the case for function parameters…
I agree that this error message looks a bit mysterious, but there is a good motivation for it. According to the F# naming guidelines, cases of discriminated unions should be named using
PascalCaseand the compiler is trying to make sure that you don’t accidentally misspell name of a case in pattern matching.For example, if you have the following union:
You could write the following function that prints “ok” when the argument is
Leftand “wrong!” otherwise:There is a typo in the code – I wrote just
Lef– but the code is still valid, becauseLefcan be interpreted as a new variable and so the matching assigns whatever side toLefand always runs the first case. The warning about uppercase identifiers helps to avoid this.