| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/fail172.d(25): Error: cannot modify `const` expression `c1.x` |
| 5 |
fail_compilation/fail172.d(26): Error: cannot modify `const` expression `c2.x` |
| 6 |
fail_compilation/fail172.d(30): Error: cannot modify `const` expression `s1.x` |
| 7 |
fail_compilation/fail172.d(31): Error: cannot modify `const` expression `s2.x` |
| 8 |
--- |
| 9 |
*/ |
| 10 |
|
| 11 |
class C |
| 12 |
{ |
| 13 |
int x; |
| 14 |
} |
| 15 |
|
| 16 |
struct S |
| 17 |
{ |
| 18 |
int x; |
| 19 |
} |
| 20 |
|
| 21 |
void main() |
| 22 |
{ |
| 23 |
const(C) c1 = new C(); |
| 24 |
const C c2 = new C(); |
| 25 |
c1.x = 3; |
| 26 |
c2.x = 3; |
| 27 |
|
| 28 |
const(S) s1; |
| 29 |
const S s2; |
| 30 |
s1.x = 3; |
| 31 |
s2.x = 3; |
| 32 |
} |