File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
tests/FSharpLint.Rules.Tests Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ module AstInfo =
103
103
104
104
isPublic true false path
105
105
106
+ /// Is an identifier being used to identify declaration of a value?
106
107
let isValue ( identifier : LongIdent ) ( checkFile : CheckFileResults ) =
107
108
if System.Char.IsUpper( identifier.Head.idText.[ 0 ]) && identifier.Length = 1 then
108
109
let identifier = identifier.Head
@@ -115,7 +116,15 @@ module AstInfo =
115
116
match symbol with
116
117
| Some( symbol) ->
117
118
match symbol.Symbol with
118
- | :? FSharpMemberFunctionOrValue -> true
119
+ | :? FSharpMemberFunctionOrValue as symbol ->
120
+ match symbol.ImplementationLocation with
121
+ | Some( implLocation) ->
122
+ /// If it's implemented elsewhere then it's not what we're looking for,
123
+ /// it's probably a literal being matched against.
124
+ let isImplementedHere = implLocation.StartRange = identifier.idRange.StartRange
125
+
126
+ isImplementedHere
127
+ | None -> true
119
128
| _ -> false
120
129
| None -> false
121
130
else
Original file line number Diff line number Diff line change @@ -366,6 +366,20 @@ namespace matt.dog.cat"""
366
366
367
367
Assert.IsTrue( this.ErrorExistsAt( 2 , 10 ))
368
368
369
+ [<Test>]
370
+ member this.LiteralPatternMatchExpectNoErrors () =
371
+ this.Parse """
372
+ module program
373
+ [<Literal>]
374
+ let Dog = true
375
+
376
+ let main =
377
+ match true with
378
+ | Dog -> ()
379
+ | _ -> ()"""
380
+
381
+ Assert.IsFalse( this.ErrorExistsAt( 8 , 6 ))
382
+
369
383
[<Test>]
370
384
member this.VariablePatternMatchIsPascalCase () =
371
385
this.Parse """
@@ -375,7 +389,7 @@ module program
375
389
| Dog -> ()"""
376
390
377
391
Assert.IsTrue( this.ErrorExistsAt( 5 , 6 ))
378
-
392
+
379
393
[<Test>]
380
394
member this.VariablePatternMatchIsCamelCase () =
381
395
this.Parse """
You can’t perform that action at this time.
0 commit comments