Skip to content

Internal error: Undefined or unsolved type variable with SRTP chains #5973

Open
@realvictorprm

Description

@realvictorprm

While digging into #4924 I found an example with SRTP chains which produces an internal error.

Repro steps

Try compiling this in FSI:

type Bar =
    static member inline bar (f: ^c -> ^b, (a, b) : ^c) : ^b = f (a, b)
    static member inline bar (f: ^c -> ^b, (a, b, c) : ^c) : ^b = f (a, b, c)

let inline bar_(f:^a -> ^b) (x: ^c) : ^d when (^bar or ^d) : (static member bar : (^a -> ^b) * ^c -> ^d) = 
    ((^bar or ^d) : (static member bar : (^a -> ^b) * ^c -> ^d)(f, x))

type Foo =
    static member inline foo (f : ^a -> ^b, (a, b)) : ^c = bar_ f (a,b)
    static member inline foo (f : ^a -> ^b, (a, b, c)) : ^c = bar_ f (a,b,c)

let inline foo< ^foo, ^a, ^b, ^c, ^d when (^foo or ^a) : (static member foo : (^a -> ^b) * ^c -> ^d)> (f: ^a -> ^b) (x: ^c) : ^d =
        ((^foo or ^a) : (static member foo : (^a -> ^b) * ^c -> ^d)(f, x))

let inline callFoo (f: ^a -> ^b) (x: ^c) : ^d when (Foo or ^d) : (static member foo: (^a -> ^b) * ^c -> ^d)=
    foo<Foo, ^a, ^b, ^c, ^d> f x

let test = (fun (a : int, b : int) -> (a, b))

let appliedFoo : int * int -> int * int =
    callFoo test

Will produce an error like: FS0073: Internal Error: Undefined or unsolved type variable: ^_?35727
for the last function appliedFoo.

Expected behavior

No internal error.

Actual behavior

An internal error is thrown.

Known workarounds

None

Related information

F# 4.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-SRTPbugs in SRTP inference, resolution, witness passing, code genBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions