Repro steps
Consider the following code:
let inline add<'T when 'T : (static member (+) : 'T * 'T -> 'T)> (a : 'T) (b : 'T) =
a + b
Expected behavior
Code should compile and successfully add the two arguments.
Actual behavior
Compiler error: A type parameter is missing a constraint 'when ( ^T or ^?11088896) : (static member (+) : ^T * ^?11088896 -> ^?11088897)'
Known workarounds
The following variation works:
let inline add<'T when 'T : (static member (+) : 'T * 'T -> 'T)> (a : 'T) (b : 'T) =
(^T : (static member (+) : ^T * ^T -> ^T)(a, b))
However, it also results in a compiler warning: Member constraints with the name 'op_Addition' are given special status by the F# compiler as certain .NET types are implicitly augmented with this member. This may result in runtime failures if you attempt to invoke the member constraint from your own code.
Repro steps
Consider the following code:
Expected behavior
Code should compile and successfully add the two arguments.
Actual behavior
Compiler error:
A type parameter is missing a constraint 'when ( ^T or ^?11088896) : (static member (+) : ^T * ^?11088896 -> ^?11088897)'Known workarounds
The following variation works:
However, it also results in a compiler warning:
Member constraints with the name 'op_Addition' are given special status by the F# compiler as certain .NET types are implicitly augmented with this member. This may result in runtime failures if you attempt to invoke the member constraint from your own code.