-
Notifications
You must be signed in to change notification settings - Fork 833
Open
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone
Description
I'm experimenting with the new System.Numerics namespace and came across an issue with generic interfaces with static abstract members. I cannot implement a generic interface with static abstract members with different generic arguments. In this example, I want to implement IMultiplyOperators<Vector, double, Vector> and IMultiplyOperators<Vector, Vector, Vector>.
open System.Numerics
type Vector = Vector of x: double * y: double * z: double with
//factor
static member (*) (Vector (x, y, z), f) =
Vector (x * f, y * f, z * f)
//cross product
static member (*) (Vector (x1, y1, z1), Vector (x2, y2, z2)) =
Vector (y1 * z2 - z1 * y2, z1 * x2 - x1 * z2, x1 * y2 - y1 * x2)
interface IMultiplyOperators<Vector, double, Vector> with
static member (*) (a, f) = a * f
interface IMultiplyOperators<Vector, Vector, Vector> with
static member (*) (a, b) = a * bI'm getting the following compiler errors:
Program.fs(13,15): error FS0001: This expression was expected to have type� 'decimal' �but here has type� 'Vector'
Program.fs(13,15): error FS0001: This expression was expected to have type� 'decimal' �but here has type� 'Vector'
Program.fs(13,15): error FS0909: All implemented interfaces should be declared on the initial declaration of the type
- net7.0
- FSharp.Core 7.0.300
- Visual Studio 17.6.5
- MSBuild version 17.6.8+c70978d4d for .NET
Metadata
Metadata
Assignees
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Type
Projects
Status
New