gcc/testsuite/gdc.test/fail_compilation/test12385.d
raw| 1 | /* |
| 2 | TEST_OUTPUT: |
| 3 | --- |
| 4 | fail_compilation/test12385.d(29): Error: cannot modify `immutable` expression `unbundled.x` |
| 5 | --- |
| 6 | */ |
| 7 | |
| 8 | // https://issues.dlang.org/show_bug.cgi?id=12385 |
| 9 | |
| 10 | class BundledState |
| 11 | { |
| 12 | string m_State; |
| 13 | |
| 14 | int x = 3; |
| 15 | |
| 16 | this(string state) immutable |
| 17 | { |
| 18 | m_State = state; |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | enum States : immutable(BundledState) |
| 23 | { |
| 24 | unbundled = new immutable BundledState("bla"), |
| 25 | } |
| 26 | |
| 27 | void main() |
| 28 | { |
| 29 | States.unbundled.x = 6; // Modifies x. |
| 30 | } |