fsharp
fsharp copied to clipboard
SRTP bug in type inference
I think it's serious:
type Ah =
static member plus (a: Ah, b: Ah) = "Ah"
type TestPlus =
static member plus(a: int, b: int) = a + b
static member plus(a: string, b: string) = a + b
static member plus (a: 'T, b: 'T) = "TestPlus"
let inline plus'< ^t,^x, ^r when (^t or ^x or ^r):(static member plus: ^x * ^x -> ^r)> a b =
((^t or ^x or ^r):(static member plus: ^x * ^x -> ^r) (a, b))
let inline plus a b = plus'<TestPlus, _, _> a b
let foo2 (a: int) (b: int) = plus a b
the code compile to :
public static int foo2(int a) (int b)
{
//IL_0006: Expected I4, but got O
return (int)"TestPlus";
}
foo2 1 2
result is -464137512
the type inference should do something here.