Bug 6216 – Built-in opAssign implicitly defined should call field's opAssign
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-06-26T10:47:00Z
Last change time
2012-10-07T11:49:05Z
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2011-06-26T10:47:27Z
Following should compile.
----
struct X
{
int n;
const void opAssign(const X rhs) {}
}
struct S
{
int n;
const(X) x;
}
void main()
{
S s;
s = s;
}
----
test.d(14): Error: variable test.main.s cannot modify struct with immutable members
----
S has implicitly defined opAssign, but it does not call field x's opAssign.
Comment #1 by github-bugzilla — 2012-10-07T09:15:13Z