Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarfgp committed Oct 14, 2022
1 parent b993efe commit 56c28c0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,34 @@ type StructUnion = A of X:int | B of Y:StructUnion
|> shouldFail
|> withDiagnostics [
(Error 954, Line 4, Col 6, Line 4, Col 17, "This type definition involves an immediate cyclic reference through a struct field or inheritance relation")
]

[<Fact>]
let ``If a union type has more than one case and is a struct, field must be given unique name 14`` () =
Fsx """
namespace Foo
[<Struct>]
type NotATree =
| Empty
| Children of struct (int * string)
"""
|> compile
|> shouldFail
|> withDiagnostics [
(Error 3204, Line 6, Col 19, Line 6, Col 40, "If a union type has more than one case and is a struct, then all fields within the union type must be given unique field names. For example: 'type A = B of b: int | C of c: int' (unique field names 'b' and 'c' assigned).")
]

[<Fact>]
let ``If a union type has more than one case and is a struct, field must be given unique name 15`` () =
Fsx """
namespace Foo
[<Struct>]
type NotATree =
| Empty
| Children of a: struct (int * string)
"""
|> compile
|> shouldFail
|> withDiagnostics [
(Error 3204, Line 6, Col 19, Line 6, Col 40, "If a union type has more than one case and is a struct, then all fields within the union type must be given unique field names. For example: 'type A = B of b: int | C of c: int' (unique field names 'b' and 'c' assigned).")
]
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ namespace FSharpTest
| Children of struct (int * string)
"""
|> compile
|> shouldSucceed
|> shouldFail
|> withErrorCode 3204
|> ignore

[<Fact>]
Expand Down

0 comments on commit 56c28c0

Please sign in to comment.