-
Notifications
You must be signed in to change notification settings - Fork 789
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a compiler warning for lower case literals in patterns
Add unit tests #666
- Loading branch information
1 parent
f5afa30
commit 4421e29
Showing
7 changed files
with
49 additions
and
4 deletions.
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
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
13 changes: 13 additions & 0 deletions
13
tests/fsharpqa/Source/Diagnostics/General/W_LowercaseLiteralIgnored.fs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// #Regression #Diagnostics | ||
//<Expects status="warning" span="(10,5-10,14)" id="FS3190">Lowercase literal 'lowerCase' is being shadowed by a new pattern with the same name\. Only uppercase and module-prefixed literals can be used as named patterns\.$</Expects> | ||
module M | ||
|
||
let [<Literal>] lowerCase = "lowerCase" | ||
let [<Literal>] UpperCase = "UpperCase" | ||
|
||
let f = function | ||
| UpperCase -> "UpperCase" | ||
| lowerCase -> "LowerCase" | ||
|
||
f "A" |> ignore | ||
|
15 changes: 15 additions & 0 deletions
15
tests/fsharpqa/Source/Diagnostics/General/W_LowercaseLiteralNotIgnored.fs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// #Regression #Diagnostics | ||
//<Expects status="warning" span="(13,7-13,8)" id="FS0026">This rule will never be matched$</Expects> | ||
module M0 | ||
|
||
module m1 = | ||
let [<Literal>] lowerCase = "lowerCase" | ||
let [<Literal>] UpperCase = "UpperCase" | ||
|
||
module M2 = | ||
let f = function | ||
| m1.lowerCase -> "LowerCase" | ||
| lowerCase2 -> "LowerCase2" | ||
| _ -> "Don't know" | ||
|
||
printfn "%A" (M2.f "B") |
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