Skip to content

Commit 68fb63d

Browse files
T-GroCopilotgithub-actions[bot]
authored
Add regression test: #6648, DU of DUs with inline static members (#19470)
* Add regression test for #6648: DU of DUs with inline static members Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix unclosed triple-quoted string in Issue 6648 regression test Add missing closing triple-quote and assertion pipeline to the DU of DUs with inline static members test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent f540da5 commit 68fb63d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/FSharp.Compiler.ComponentTests/ConstraintSolver/MemberConstraints.fs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,42 @@ ignore ["1" .. "42"]
114114
|> withSingleDiagnostic
115115
(Error 1, Line 2, Col 9, Line 2, Col 12, "The type 'string' does not support the operator 'op_Range'")
116116

117+
// https://github.com/dotnet/fsharp/issues/6648
118+
[<Fact>]
119+
let ``Issue 6648 - DU of DUs with inline static members should compile`` () =
120+
FSharp
121+
"""
122+
type SomeUnion1<'T> =
123+
| Case1A of 'T
124+
| Case1B of 'T
125+
static member inline (-) (a, b) =
126+
match a, b with
127+
| Case1A x, Case1A y -> Case1A(x - y)
128+
| Case1B x, Case1B y -> Case1B(x - y)
129+
| _ -> failwith "mismatch"
130+
131+
type SomeUnion2<'T> =
132+
| Case2A of 'T
133+
| Case2B of 'T
134+
static member inline (-) (a, b) =
135+
match a, b with
136+
| Case2A x, Case2A y -> Case2A(x - y)
137+
| Case2B x, Case2B y -> Case2B(x - y)
138+
| _ -> failwith "mismatch"
139+
140+
type UnionOfUnions<'T> =
141+
| ParentCase1 of SomeUnion1<'T>
142+
| ParentCase2 of SomeUnion2<'T>
143+
static member inline (-) (a, b) =
144+
match a, b with
145+
| ParentCase1 x, ParentCase1 y -> x - y |> ParentCase1
146+
| ParentCase2 x, ParentCase2 y -> x - y |> ParentCase2
147+
| _ -> failwith "mismatch"
148+
"""
149+
|> asLibrary
150+
|> typecheck
151+
|> shouldSucceed
152+
117153
// https://github.com/dotnet/fsharp/issues/9382
118154
[<Fact>]
119155
let ``Issue 9382 - SRTP stress test with matrix inverse should compile`` () =

0 commit comments

Comments
 (0)