struct S
{
void opBinary(string op)(ref S rhs)
{}
}
void main()
{
auto result = S() + S();
}
Error: incompatible types for ((S()) + (S())): 'S' and 'S'
The message is bogus because S is compatible with S. ;)
Comment #1 by n8sh.secondary — 2019-08-23T21:28:02Z
There is no issue with both operands being S. The issue seems to be the fact that the second operand is an rvalue.
So, a helpful message would be "cannot bind rvalue S to ref parameter".
Ali
Comment #3 by robert.schadek — 2024-12-13T18:38:14Z