I have the following simple type:
module Structures
type Point2D<'T> (x : 'T, y : 'T) =
member this.X = x
member this.Y = y
member this.IsEqualTo (p : Point2D<'T>) =
(this.X = p.X) && (this.Y = p.Y)
But Visual Studio (2012 Trial Version) places a red squiggly line under the name “IsEqualTo,” and a blue squiggly line under “this.X.”
The error message for the red squiggly line is as follows:
The generic member IsEqualTo has been used at a non-uniform instantiation prior to this program point. Consider reordering the members so this member occurs first. Alternatively, specify the full type of the members explicitly, including argument types, return types and any additional generic parameters and constraints.
The message for the blue line is:
A type parameter is missing a constraint ‘when ‘T : equality’
I’ve tried placing “IsEqualTo” before all the other members, but the error persists.
I’m guessing the error has something to do with the fact that the = sign in this.X = p.X is working over the generic type 'T but I can’t seem to correct it.
Thank you in advance for your help.
1 Answer