-
Notifications
You must be signed in to change notification settings - Fork 790
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 15958: Missing warning FS3365 for SynLongIdent (dotless indexing …
…vs application) (#16224) * Add tests for FS3365 * improve tests * add missing warning for 3365 * format * refactor
- Loading branch information
Showing
3 changed files
with
89 additions
and
7 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
74 changes: 74 additions & 0 deletions
74
tests/FSharp.Compiler.ComponentTests/ErrorMessages/IndexingSyntax.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,74 @@ | ||
namespace FSharp.Compiler.ComponentTests.ErrorMessages | ||
|
||
open FSharp.Test.Compiler | ||
open FSharp.Test.Compiler.Assertions.StructuredResultsAsserts | ||
|
||
module ``Indexing Syntax`` = | ||
|
||
[<FSharp.Test.FactForNETCOREAPP>] | ||
let ``Warn successfully for SynExpr.Ident app`` () = | ||
""" | ||
namespace N | ||
module M = | ||
let f (a: int list) = a | ||
let g () = f [1] // should not warn | ||
let h () = f[1] // should warn | ||
""" | ||
|> FSharp | ||
|> withLangVersion70 | ||
|> compile | ||
|> shouldFail | ||
|> withResults | ||
[ | ||
{ | ||
Error = Information 3365 | ||
Range = | ||
{ | ||
StartLine = 10 | ||
StartColumn = 20 | ||
EndLine = 10 | ||
EndColumn = 24 | ||
} | ||
Message = | ||
"The syntax 'expr1[expr2]' is used for indexing. Consider adding a type annotation to enable indexing, or if calling a function add a space, e.g. 'expr1 [expr2]'." | ||
} | ||
] | ||
|
||
[<FSharp.Test.FactForNETCOREAPP>] | ||
let ``Warn successfully for SynExpr.LongIdent app`` () = | ||
""" | ||
namespace N | ||
module N = | ||
type C () = | ||
member _.MyFunc (inputList: int list) = inputList | ||
let g () = | ||
let c = C() | ||
let _ = c.MyFunc [23] // should not warn | ||
c.MyFunc[42] // should warn | ||
""" | ||
|> FSharp | ||
|> withLangVersion70 | ||
|> compile | ||
|> shouldFail | ||
|> withResults | ||
[ | ||
{ | ||
Error = Information 3365 | ||
Range = | ||
{ | ||
StartLine = 12 | ||
StartColumn = 13 | ||
EndLine = 12 | ||
EndColumn = 25 | ||
} | ||
Message = | ||
"The syntax 'expr1[expr2]' is used for indexing. Consider adding a type annotation to enable indexing, or if calling a function add a space, e.g. 'expr1 [expr2]'." | ||
} | ||
] |
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