[Issue 20917] New: stacking alias this, drops data during assignment
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 9 21:35:15 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20917
Issue ID: 20917
Summary: stacking alias this, drops data during assignment
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: crazymonkyyy at gmail.com
struct ihatecompilers(T,size_t n){
struct hate{
T payload; alias payload this;
float depthofhatred=float.max;
}
hate data;
void opAssign(T a){
data=a;
import std.stdio;
data.writeln;
assert(data==a);
}
}
unittest{
struct inner{int a;}
struct outer{
inner payload;alias payload this;
string metadata;
}
ihatecompilers!(outer,100) foo;
inner bar= inner(10);
foo=outer(bar,"very very very important data");
}
foo is assigned as outer(inner(10),""), droping the very very important data
--
More information about the Digitalmars-d-bugs
mailing list