Skip to content

SRTP Regression in .net SDK release 7.0.400 #15987

Closed

Description

@wallymathieu

Repro steps

  1. Create a global.json to fix .net to the version you want to test
  2. Create a repro.fsx with the following content:
#r "nuget: FSharpPlus"

open FSharpPlus

module Probability =

    type Prob<'t> = Prob of List<'t * float>

    type Prob<'a> with
        static member probMap f (Prob prob : Prob<'a>) : Prob<'b> = List.map (fun (x, p) -> (f x, p)) prob |> Prob
        static member flatten (Prob xs : Prob<Prob<'a>>) : Prob<'a> =
            let multAll (Prob innerxs, p) = List.map (fun (x, r) -> (x, p * r)) innerxs
            Prob (List.map multAll xs |> List.concat)
        static member Map (prob:Prob<'a>, f) =
            Prob.probMap f prob : Prob<'b>
        static member Return (x) =
            Prob [(x, 1.0)] : Prob<'a>
        static member (>>=) (prob:Prob<'a>, f:'a -> Prob<'b>) =
            Prob.flatten (map f prob) : Prob<'b>

open Probability

let res120 = map (fun x -> -x) (Prob [(3, 0.5); (5, 0.25); (9, 0.25)])                // Prob [(-3, 0.5); (-5, 0.25); (-9, 0.25)]

type Coin =
    | Heads
    | Tails

let coin = Prob [(Heads, 0.5); (Tails, 0.5)]                                          // Prob [(Heads, 0.5); (Tails, 0.5)]
let loadedCoin = Prob [(Heads, 0.1); (Tails, 0.9)]                                    // Prob [(Heads, 0.1); (Tails, 0.9)]

// Prob [(false, 0.025); (false, 0.225); (false, 0.025); (false, 0.225);
//       (false, 0.025); (false, 0.225); (false, 0.025); (true, 0.225)]
let flipThree : Prob<bool> =
    monad {
        let! a = coin
        let! b = coin
        let! c = loadedCoin
        return [a;b;c] |> List.forall (fun x -> x = Tails)
    }
  1. Run dotnet fsi --exec ./repro.fsx to verify the result

Otherwise use the zip provided:
repro.fsx.zip

Expected behavior

In .net sdk 7.0.308 and prior we get successful execution.

Actual behavior

Running the above script for .net sdk 7.0.400, 7.0.401, 8.0.100-rc.1.23455.8 gives an error:

/Users/mathieu/src/fs/overload-resolution-repro/unknown(1,1): error FS0073: internal error: Undefined or unsolved type variable: ^_?86737

Known workarounds

Provide a description of any known workarounds.

Related information

Provide any related information (optional):

  • .NET Runtime kind 7.0.400, 7.0.401, 8.0.100-rc.1.23455.8

Activity

  1. added this to the Backlog milestone on Sep 16, 2023
  2. added
    Area-Compiler-SRTP
    and removed on Sep 18, 2023
  3. github-actions commented on Mar 30, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    This issue appears to be fixed in the current F# 11.0 development build.

    Verification — tested on commit a0cce49 (dotnet/fsharp main, 2026-03-30) using F# Interactive 15.2.100.0 for F# 11.0:

    #r "nuget: FSharpPlus, 1.6.1"
    open FSharpPlus
    
    module Probability =
        type Prob<'t> = Prob of List<'t * float>
        type Prob<'a> with
            static member probMap f (Prob prob : Prob<'a>) : Prob<'b> = List.map (fun (x, p) -> (f x, p)) prob |> Prob
            static member flatten (Prob xs : Prob<Prob<'a>>) : Prob<'a> =
                let multAll (Prob innerxs, p) = List.map (fun (x, r) -> (x, p * r)) innerxs
                Prob (List.map multAll xs |> List.concat)
            static member Map (prob:Prob<'a>, f) = Prob.probMap f prob : Prob<'b>
            static member Return (x) = Prob [(x, 1.0)] : Prob<'a>
            static member (>>=) (prob:Prob<'a>, f:'a -> Prob<'b>) = Prob.flatten (map f prob) : Prob<'b>
    
    open Probability
    
    let res120 = map (fun x -> -x) (Prob [(3, 0.5); (5, 0.25); (9, 0.25)])
    
    type Coin = Heads | Tails
    let coin = Prob [(Heads, 0.5); (Tails, 0.5)]
    let loadedCoin = Prob [(Heads, 0.1); (Tails, 0.9)]
    
    let flipThree : Prob<bool> =
        monad {
            let! a = coin
            let! b = coin
            let! c = loadedCoin
            return [a;b;c] |> List.forall (fun x -> x = Tails)
        }
    ```
    
    **Output:**
    ```
    res120: Prob [(-3, 0.5); (-5, 0.25); (-9, 0.25)]
    flipThree: Prob [(false, 0.025); (false, 0.225); (false, 0.025); (false, 0.225);
                     (false, 0.025); (false, 0.225); (false, 0.025); (true, 0.225)]

    The FS0073: internal error: Undefined or unsolved type variable no longer occurs. The fix presumably landed as part of the SRTP improvements in F# 8.0+.

    Generated by Repo Assist · ◷

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@9135cdfde26838a01779aa966628308404ec1f02
    
  4. added a commit that references this issue on Mar 31, 2026
  5. added a commit that references this issue on Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    AI-thinks-issue-fixedArea-Compiler-SRTPBug

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions