F# does allow overloading of arithmetic operators like +, but seems to disallow this for boolean operators like ||. The following code generates a warning and two errors:
type MyBool =
val Value : bool
new(value) = { Value = value }
static member (||) (v1: MyBool, v2 : MyBool) =
new MyBool(v1.Value || v2.Value)
let b1 = new MyBool(true)
let b2 = new MyBool(false)
let b3 = b1 || b2
Warning (on the static member (||) definition): The name '(||)' should not be used as a member name. If defining a static member for use from other CLI languages then use the name 'op_BooleanOr' instead.
Error (on b1 and b2 in the 'let b3' statement): This expression was expected to have type bool but here has type MyBool
If I use op_BooleanOr instead of (||) the warning disappears, but the errors remain.
When I do exactly the same thing for the + operator in a MyInt type there are no warnings or errors. So, why do these warnings/errors appear when I try to overload || or &&?