I am writing a simple 2d physics engine and I've overridden == for my Vector2 struct as follows:
[Pure]
public static bool operator ==(Vector2 v1, Vector2 v2)
{
Contract.Ensures(Contract.Result<bool>() == (v1.x == v2.x && v1.y == v2.y));
return v1.x == v2.x && v1.y == v2.y;
}
However, when I go to use this in a Contract.Ensures for my Circle struct, I get the following:
public Vector2 Position
{
get
{
Contract.Ensures(Contract.Result<Vector2>() == position);
Contract.Assert(position == position); // Assert unproven: position == position
return position;
}
}
I added the assert as a way of debugging. position is just a private Vector2 field, and it is set by the sole Circle constructor in the struct. Vector2 is itself a struct.