The following F# code
let f<'T when 'T: (member Id:int)> (t:'T) = t.Id
is not accepted with the following error:
Error FS0670 This code is not sufficiently generic. The type variable ^T when ^T : (member get_Id : ^T -> int) could not be generalized because it would escape its scope.
What's wrong? How to fix it?
EDIT
@Fyodor: tricky! I did some tests and found more strangeness:
let inline f1<^T when ^T: (member Id:int)> (t:^T) = ( ^T: (member Id:int) t )
let inline f2<'T when 'T: (member Id:int)> (t:'T) = ( 'T: (member Id:int) t )
let inline f3<'T when 'T: (member Id:int)> (t:'T) = ( ^T: (member Id:int) t )
let inline f4 t = ( ^T: (member Id:int) t )
f1 gives error in <^T
Error FS0010 Unexpected infix operator in pattern
f2 gives errors in ( 'T
Error FS0583 Unmatched '('
Error FS0010 Unexpected quote symbol in binding
f3 and f4 are accepted