[Issue 19441] New: alias this causes partial assignment
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 28 13:25:43 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19441
Issue ID: 19441
Summary: alias this causes partial assignment
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: eyal at weka.io
Reproducing example:
struct S1 {
int a;
long b;
alias a this;
}
struct S2 {
S1 v;
alias v this;
}
unittest {
import std.stdio;
auto x = S2(S1(1, 12345678));
writeln(x.a, " ", x.b); // prints: 1 12345678
S1 y;
y = x;
writeln(y.a, " ", y.b); // prints: 1 0
y = x.v;
writeln(y.a, " ", y.b); // prints: 1 12345678
}
I think the LHS of assignment should probably not respect `alias this` at all,
as assignment is expected to replace the whole value. If it does, it should go
thru as few alias-this's as possible.
--
More information about the Digitalmars-d-bugs
mailing list