Skip to content

Commit 98c4774

Browse files
T-GroCopilot
andauthored
Add regression tests for #10043: backtick, @, and ! in type annotations (#19476)
Verifies that type annotations with invalid characters produce clear error messages: - backtick: FS3563 'This is not a valid identifier' - at sign: FS0615 'Unexpected infix operator in type expression' - bang: FS1141 'Identifiers followed by ! are reserved for future use' Fixes #10043 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ead77d1 commit 98c4774

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/FSharp.Compiler.ComponentTests/ErrorMessages/DiagnosticRegressionTests.fs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,43 @@ type Vehicle() = class end
5050
[ (Error 39, Line 3, Col 14, Line 3, Col 28, "The type 'OutOfScopeType' is not defined.")
5151
(Error 267, Line 3, Col 7, Line 3, Col 29, "This is not a valid constant expression or custom attribute value") ]
5252

53+
// https://github.com/dotnet/fsharp/issues/10043
54+
[<Fact>]
55+
let ``Issue 10043 - backtick in type annotation should not report unexpected keyword`` () =
56+
FSharp
57+
"""
58+
let i:float`1 = 3.0
59+
"""
60+
|> typecheck
61+
|> shouldFail
62+
|> withDiagnostics
63+
[ (Error 3563, Line 2, Col 12, Line 2, Col 13, "This is not a valid identifier")
64+
(Error 10, Line 2, Col 13, Line 2, Col 14, "Unexpected integer literal in binding. Expected '=' or other token.") ]
65+
66+
// https://github.com/dotnet/fsharp/issues/10043
67+
[<Fact>]
68+
let ``Issue 10043 - at sign in type annotation should report infix operator`` () =
69+
FSharp
70+
"""
71+
let i:float@1 = 3.0
72+
"""
73+
|> typecheck
74+
|> shouldFail
75+
|> withDiagnostics
76+
[ (Error 615, Line 2, Col 12, Line 2, Col 13, "Unexpected infix operator in type expression") ]
77+
78+
// https://github.com/dotnet/fsharp/issues/10043
79+
[<Fact>]
80+
let ``Issue 10043 - bang in type annotation should report reserved identifier`` () =
81+
FSharp
82+
"""
83+
let i:float!1 = 3.0
84+
"""
85+
|> typecheck
86+
|> shouldFail
87+
|> withDiagnostics
88+
[ (Error 1141, Line 2, Col 7, Line 2, Col 13, "Identifiers followed by '!' are reserved for future use")
89+
(Error 10, Line 2, Col 13, Line 2, Col 14, "Unexpected integer literal in binding. Expected '=' or other token.") ]
5390

5491
// https://github.com/dotnet/fsharp/issues/7177
5592
[<Fact>]

0 commit comments

Comments
 (0)