Skip to content

SRTP Regression in .net SDK release 7.0.400 #15987

Open
@wallymathieu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-SRTPbugs in SRTP inference, resolution, witness passing, code genBug

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions