diff --git a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/TaskCETypeInference.fs b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/TaskCETypeInference.fs new file mode 100644 index 00000000000..a02427f567f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/TaskCETypeInference.fs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.ComponentTests.ConstraintSolver + +open Xunit +open FSharp.Test.Compiler + +module TaskCETypeInference = + + // https://github.com/dotnet/fsharp/issues/14596 + [] + let ``Issue 14596 - Type inference in backgroundTask CE should not produce FS0073`` () = + FSharp + """ +module UnresolvedTypeVarBug + +type IMarker<'T> = interface end +type SomeAction<'T when 'T :> IMarker<'T>> = SomeAction of list<'T> +type Spec<'Action> = { Dummy: unit } + +open System.Threading.Tasks + +let dummyTask (_spec: Spec<'Action>) (_action: 'Action) : Task> = failwith "not implemented" + +let repro (spec: Spec>) + : Task> = + + backgroundTask { + let action = SomeAction [] + let! res = dummyTask spec action + + match res with + | Ok _ -> + return Ok () + | Error err -> + return Error err + } + """ + |> asLibrary + |> typecheck + |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 194292ab223..1f366be8689 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -403,6 +403,7 @@ +