Description
Calling op_Addition on primitive types doesn't work but works on new BCL types.
Repro steps
> System.Int32.op_Addition (3, 6) ;;
System.Int32.op_Addition (3, 6) ;;
-------------^^^^^^^^^^^
C:\Repos\stdin(3,14): error FS0039: The type 'Int32' does not define the field, constructor or member '+'.
but
> System.Int128.op_Addition (3, 6) ;;
val it: System.Int128 = 9
Expected behavior
Same in both cases
Actual behavior
The former doesn't work, the latter does.
Known workarounds
Don't do it.
Related information
In case this is somehow expected we need to document this in the RFC.
Also I wonder if the definition of standard F# operators is adapted in order to work on new BCL interfaces like IAdditionOperators
, it seems they are not, which means if I define my own type implementing IAdditionOperators
I won't be able to just use F# standard +
operator, without having to redefine it. The RFC doesn't mention about adjusting existing math operators, maybe it should clarify.
Microsoft (R) F# Interactive version 12.0.5.0 for F# 7.0
Microsoft Visual Studio Community 2022 (64-bit) - Preview
Version 17.4.0 Preview 2.1
Metadata
Metadata
Assignees
Type
Projects
Status