1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/diag8777.d(12): Error: constructor diag8777.Foo1.this missing initializer for immutable field x
5 fail_compilation/diag8777.d(12): Error: constructor diag8777.Foo1.this missing initializer for const field y
6 ---
7 */
8 class Foo1
9 {
10     immutable int[5] x;
11     const int[5] y;
this()12     this() {}
13 }
14 
15 /*
16 TEST_OUTPUT:
17 ---
18 fail_compilation/diag8777.d(25): Error: cannot modify immutable expression x
19 fail_compilation/diag8777.d(28): Error: cannot modify const expression y
20 ---
21 */
test2()22 void test2()
23 {
24     immutable int x;
25     x = 1;
26 
27     const int y;
28     y = 1;
29 }
30 
31 /*
32 TEST_OUTPUT:
33 ---
34 fail_compilation/diag8777.d(42): Error: cannot remove key from immutable associative array hashx
35 fail_compilation/diag8777.d(43): Error: cannot remove key from const associative array hashy
36 ---
37 */
38 immutable(int[int]) hashx;
39 const(int[int]) hashy;
test3()40 void test3()
41 {
42     hashx.remove(1);
43     hashy.remove(1);
44 }
45