gcc/testsuite/gdc.test/fail_compilation/fail340.d
raw| 1 | /* |
| 2 | TEST_OUTPUT: |
| 3 | --- |
| 4 | fail_compilation/fail340.d(18): Error: variable `fail340.w` of type struct `const(CopyTest)` uses `this(this)`, which is not allowed in static initialization |
| 5 | fail_compilation/fail340.d(19): while evaluating: `static assert(w.x == 55.0)` |
| 6 | --- |
| 7 | */ |
| 8 | |
| 9 | struct CopyTest |
| 10 | { |
| 11 | double x; |
| 12 | this(double a) { x = a * 10.0;} |
| 13 | this(this) { x += 2.0; } |
| 14 | } |
| 15 | |
| 16 | const CopyTest z = CopyTest(5.3); |
| 17 | |
| 18 | const CopyTest w = z; |
| 19 | static assert(w.x == 55.0); |