Re: struct opEquals bug

2011-02-17 Thread Jason House
Sean Eskapp Wrote:

 Has this been reported?

Do what any of us would do... Search bugzilla and that as a bug if you don't 
find it.


Re: struct opEquals bug

2011-02-17 Thread Don

Sean Eskapp wrote:

Has this been reported?

struct A
{
int x;

A foo()
{
return A(x);
}

const bool opEquals(ref const A other)
{
return (x == other.x);
}
}

void main()
{
auto a = A(5);
assert(a == a.foo); // Error
assert(a.foo == a); // OK
}

The first assert fails to compile because a.foo isn't an lvalue, but the
second assert compiles fine. However, the language documentation states that

...the expressions a.opEquals(b) and b.opEquals(a) are tried. If both resolve
to the same opEquals function, then the expression is rewritten to be
a.opEquals(b).
If one is a better match then the other, or one compiles and the other does
not, the one is selected.
Otherwise, an error results.

In this case, a.opEquals(b) doesn't compile, but b.opEquals(a) does, so it
should be selected.


Yes, it is bug 3659.