Bug in compiler?
Shachar Shemesh via Digitalmars-d
digitalmars-d at puremagic.com
Mon Dec 15 06:01:35 PST 2014
Please consider the following program:
import std.exception;
void main()
{
struct A {
int a;
@disable this(this);
@disable ref A opAssign(const ref A);
ref A opOpAssign(string op: "~")(int data) {
a += data;
return this;
}
}
auto a = A(2);
a ~= 3;
assertThrown!Exception(a ~= 3);
}
Compilation (dmd 2.066.1) fails on the assertThrown line:
Error: struct test.main.A is not copyable because it is annotated with
@disable
What I do not understand is why A should need to be copyable. Where is
the copy made? I'm guessing this is because of the lazy definition of
the expression, but still I don't see any reason to create a copy.
Help?
Shachar
More information about the Digitalmars-d
mailing list