1 /* 2 TEST_OUTPUT: 3 --- 4 fail_compilation/fail180.d(23): Error: cannot modify this.x in const function 5 fail_compilation/fail180.d(24): Error: cannot modify this.x in const function 6 fail_compilation/fail180.d(38): Error: cannot modify this.x in const function 7 fail_compilation/fail180.d(39): Error: cannot modify this.x in const function 8 fail_compilation/fail180.d(50): Error: variable fail180.main.t cannot be final, perhaps you meant const? 9 fail_compilation/fail180.d(62): Error: variable fail180.test.d cannot be final, perhaps you meant const? 10 --- 11 */ 12 13 struct S59 14 { 15 int x; 16 fooS5917 void foo() 18 { 19 x = 3; 20 } barS5921 const void bar() 22 { 23 x = 4; 24 this.x = 5; 25 } 26 } 27 28 class C 29 { 30 int x; 31 foo()32 void foo() 33 { 34 x = 3; 35 } bar()36 const void bar() 37 { 38 x = 4; 39 this.x = 5; 40 } 41 } 42 main()43void main() 44 { 45 S59 s; 46 47 s.foo(); 48 s.bar(); 49 50 final S59 t; 51 t.foo(); 52 t.bar(); 53 } 54 test()55void test() 56 { 57 C c = new C; 58 59 c.foo(); 60 c.bar(); 61 62 final C d = new C; 63 d.foo(); 64 d.bar(); 65 } 66