On Sunday, 13 October 2013 at 21:37:31 UTC, Maurice wrote:
Hello,
Can anybody explain my what is happening here?
enum xxx = true;
struct A {
static if (xxx) ref A opAssign(ref const A a) { return this; }
ref A opAssign(int v) { return this; }
}
struct B {
A a;
alias a this;
}
void main() {
A a;
B b;
a = b; // [1]
b = a; // [2]
}
When xxx is false:
[1] Gives an error
[2] Compiles fine
When xxx is true:
[1] Compiles fine
[2] Gives an error
What exactly is happening here? When xxx is false, what does 'b
= a' do that is wrong when xxx is true?
I can't find any clear documentation about opAssign and its
'default' implementation.
Thanks!
-Maurice-
It is a bug from my POV