struct S1 {
int opBinary(string op)(S2 other) {
return 3;
}
}
struct S2 {
int opBinaryRight(string op)(S1 other) {
return 4;
}
}
void main( )
S1.init + S2.init;
}
foo.d(97): Error: overloads pure nothrow @safe int(S2 other) and pure nothrow @safe int(S1 other) both match argument list for opBinary
I would really like to see some more information here - FQN and line numbers would go a long way.
Comment #1 by dlang-bugzilla — 2017-07-21T09:33:40Z
The test case above now incorrectly compiles due to issue 17674, but the bug here can still be observed with the old opXXX operator overloading method.
//////////////// test.d ///////////////
struct S1
{
int opAdd(S2 other) { return 3; }
}
struct S2
{
int opAdd_r(S1 other) { return 3; }
}
void main()
{
auto x = S1.init + S2.init;
}
///////////////////////////////////////
Comment #2 by robert.schadek — 2024-12-13T18:08:39Z