You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let inlineadd<'Twhen'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 inlineadd<'Twhen'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.