未验证 提交 9d825921 编写于 作者: E Edgar Gonzalez 提交者: GitHub

Use more a more accurate range when reporing an error on delegate type declaration (#14208)

上级 67b09db0
......@@ -3161,7 +3161,10 @@ module EstablishTypeDefinitionCores =
| None -> ()
| Some spats ->
let ctorArgNames, _ = TcSimplePatsOfUnknownType cenv true CheckCxs envinner tpenv spats
if not ctorArgNames.IsEmpty then errorR (Error(FSComp.SR.parsOnlyClassCanTakeValueArguments(), m))
if not ctorArgNames.IsEmpty then
match spats with
| SynSimplePats.SimplePats(_, m) -> errorR (Error(FSComp.SR.parsOnlyClassCanTakeValueArguments(), m))
| SynSimplePats.Typed(_, _, m) -> errorR (Error(FSComp.SR.parsOnlyClassCanTakeValueArguments(), m))
let envinner = AddDeclaredTypars CheckForDuplicateTypars (tycon.Typars m) envinner
let envinner = MakeInnerEnvForTyconRef envinner thisTyconRef false
......
......@@ -17,8 +17,9 @@ namespace FSharpTest
"""
|> compile
|> shouldFail
|> withErrorCode 552
|> withErrorMessage "Only class types may take value arguments"
|> withDiagnostics [
(Error 552, Line 3, Col 11, Line 3, Col 19, "Only class types may take value arguments")
]
[<Fact>]
let ``Delegate definition with primary constructor no argument.`` () =
......@@ -30,8 +31,10 @@ namespace FSharpTest
"""
|> compile
|> shouldFail
|> withErrorCode 552
|> withErrorMessage "Only class types may take value arguments"
|> shouldFail
|> withDiagnostics [
(Error 552, Line 3, Col 11, Line 3, Col 13, "Only class types may take value arguments")
]
[<Fact>]
let ``Delegate definition`` () =
......
type T(x: int) =
delegate of int -> int
type T() =
delegate of int -> int
\ No newline at end of file
invalid_delegate_definition.fs (1,6)-(1,15) Only class types may take value arguments
invalid_delegate_definition.fs (4,6)-(1,9) Only class types may take value arguments
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册