From 7ad57e62ee6dfa1574d77e38e4cbe76df0dd458b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 13 Aug 2026 13:10:53 +0000 Subject: [PATCH] Add regression test for #14596: type inference in task CE Fixes https://github.com/dotnet/fsharp/issues/14596 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../ConstraintSolver/TaskCETypeInference.fs | 41 +++++++++++++++++++ .../FSharp.Compiler.ComponentTests.fsproj | 1 + 2 files changed, 42 insertions(+) create mode 100644 tests/FSharp.Compiler.ComponentTests/ConstraintSolver/TaskCETypeInference.fs 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 @@ +