Internal error: Undefined or unsolved type variable with SRTP chains
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 144
Description
While digging into #4924 I found an example with SRTP chains which produces an internal error.
#### Repro steps
Try compiling this in FSI:
```fsharp
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 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
Contributor guide
Assessment
This issue has not been assessed yet.