-
Notifications
You must be signed in to change notification settings - Fork 789
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cyclic check for struct tuple and tests (#10645)
- Loading branch information
1 parent
b4cc1c8
commit c0d2aa1
Showing
3 changed files
with
103 additions
and
1 deletion.
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
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
96 changes: 96 additions & 0 deletions
96
tests/FSharp.Compiler.ComponentTests/TypeChecks/CheckDeclarationsTests.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,96 @@ | ||
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
||
namespace FSharp.Compiler.ComponentTests.CheckDeclarationsTests | ||
|
||
open Xunit | ||
open FSharp.Test.Utilities.Compiler | ||
open FSharp.Test.Utilities.Xunit.Attributes | ||
|
||
module CheckDeclarationsTests = | ||
|
||
[<Fact>] | ||
let ``CheckingSyntacticTypes - TcTyconDefnCore_CheckForCyclicStructsAndInheritance - Struct DU with Cyclic Tuple`` () = | ||
FSharp """ | ||
namespace FSharpTest | ||
[<Struct>] | ||
type Tree = | ||
| Empty | ||
| Children of Tree * Tree | ||
""" | ||
|> compile | ||
|> shouldFail | ||
|> withErrorCode 954 | ||
|> ignore | ||
|
||
[<Fact>] | ||
let ``CheckingSyntacticTypes - TcTyconDefnCore_CheckForCyclicStructsAndInheritance - Struct DU with Cyclic Struct Tuple`` () = | ||
FSharp """ | ||
namespace FSharpTest | ||
[<Struct>] | ||
type Tree = | ||
| Empty | ||
| Children of struct (Tree * Tree) | ||
""" | ||
|> compile | ||
|> shouldFail | ||
|> withErrorCode 954 | ||
|> ignore | ||
|
||
[<Fact>] | ||
let ``CheckingSyntacticTypes - TcTyconDefnCore_CheckForCyclicStructsAndInheritance - Struct DU with Cyclic Struct Tuple of int, Tree`` () = | ||
FSharp """ | ||
namespace FSharpTest | ||
[<Struct>] | ||
type Tree = | ||
| Empty | ||
| Children of struct (int * Tree) | ||
""" | ||
|> compile | ||
|> shouldFail | ||
|> withErrorCode 954 | ||
|> ignore | ||
|
||
[<Fact>] | ||
let ``CheckingSyntacticTypes - TcTyconDefnCore_CheckForCyclicStructsAndInheritance - Struct DU with Cyclic Tree`` () = | ||
FSharp """ | ||
namespace FSharpTest | ||
[<Struct>] | ||
type Tree = | ||
| Empty | ||
| Children of Tree | ||
""" | ||
|> compile | ||
|> shouldFail | ||
|> withErrorCode 954 | ||
|> ignore | ||
|
||
[<Fact>] | ||
let ``CheckingSyntacticTypes - TcTyconDefnCore_CheckForCyclicStructsAndInheritance - Struct DU with Non-cyclic Struct Tuple`` () = | ||
FSharp """ | ||
namespace FSharpTest | ||
[<Struct>] | ||
type NotATree = | ||
| Empty | ||
| Children of struct (int * string) | ||
""" | ||
|> compile | ||
|> shouldSucceed | ||
|> ignore | ||
|
||
[<Fact>] | ||
let ``CheckingSyntacticTypes - TcTyconDefnCore_CheckForCyclicStructsAndInheritance - Non-Struct DU Tree Cyclic Tree`` () = | ||
FSharp """ | ||
namespace FSharpTest | ||
type Tree = | ||
| Empty | ||
| Children of Tree | ||
""" | ||
|> compile | ||
|> shouldSucceed | ||
|> ignore |