gcc/testsuite/gdc.test/runnable/test19441.d
raw| 1 | // https://issues.dlang.org/show_bug.cgi?id=19441 |
| 2 | struct S1 |
| 3 | { |
| 4 | int a; |
| 5 | long b; |
| 6 | alias a this; |
| 7 | } |
| 8 | |
| 9 | struct S2 |
| 10 | { |
| 11 | S1 v; |
| 12 | alias v this; |
| 13 | } |
| 14 | |
| 15 | void main() |
| 16 | { |
| 17 | auto x = S2(S1(1, 12345678)); |
| 18 | assert(x.a == 1 && x.b == 12345678); // prints: 1 12345678 |
| 19 | S1 y; |
| 20 | y = x; |
| 21 | assert(y.a == 1 && y.b == 12345678); |
| 22 | y = x.v; |
| 23 | assert(y.a == 1 && y.b == 12345678); |
| 24 | } |