From 892597f0b4a399343f636e1cda5743c36ab38659 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 31 Mar 2026 13:29:30 +0000 Subject: [PATCH] Add regression test: #16007, SRTP ctor constraint no longer causes value restriction Fixes https://github.com/dotnet/fsharp/issues/16007 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Language/RegressionTests.fs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/FSharp.Compiler.ComponentTests/Language/RegressionTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/RegressionTests.fs index f035c28b519..3b7d1a2b3a5 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/RegressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/RegressionTests.fs @@ -68,3 +68,17 @@ let x = 15 |> asLibrary |> typecheck |> shouldSucceed + + // https://github.com/dotnet/fsharp/issues/16007 + [] + let ``Issue 16007 - SRTP ctor constraint should not cause value restriction error`` () = + FSharp """ +type T() = class end +let dosmth (a: T) = System.Console.WriteLine(a.ToString()) +let inline NEW () = (^a : (new : unit -> ^a) ()) +let x = NEW () +dosmth x + """ + |> asLibrary + |> typecheck + |> shouldSucceed