I'm experiencing a lot of unexplained behavior with the type inference of F# (or lack of inference rather).
I would expect that all the value functions below would return the correct type T given a Foo of T but in several cases it returns an obj.
type Foo<'T>(v:'T) =
member __.Value = v // 'T
static member (~~) (foo:Foo<_>) = foo.Value // Foo<'a> -> 'a
// should know the type but not always!
~~(Foo 1) // int
let value (u:Foo<_>) = u.Value // Foo<'a> -> 'a
let value (u:Foo<_>) = ~~u // Foo<obj> -> obj
let inline value (u:Foo<_>) = ~~u // Foo< ^a> -> ^a
let (~~) (foo:Foo<_>) = (Foo<_>.(~~))foo // Foo<'a> -> 'a
let value (u:Foo<_>) = ~~u // Foo<'a> -> 'a
let inline (~~) (x:^a) : ^b =
(^a : (static member (~~) : ^a -> ^b) x) // ^a -> ^b
let value (u:Foo<_>) = ~~u // Foo<obj> -> obj
let inline (~~) (x:^a) : 'b =
(^a : (static member (~~) : ^a -> 'b) x) // ^a -> 'b
let value (u:Foo<_>) = ~~u // Foo<'a> -> 'a
What is going on??