1 /* 2 TEST_OUTPUT: 3 --- 4 fail_compilation/diag12829.d(12): Error: function diag12829.test1 is @nogc yet allocates closures with the GC 5 fail_compilation/diag12829.d(15): diag12829.test1.__lambda1 closes over variable x at fail_compilation/diag12829.d(14) 6 fail_compilation/diag12829.d(19): diag12829.test1.bar closes over variable x at fail_compilation/diag12829.d(14) 7 fail_compilation/diag12829.d(26): Error: function diag12829.test2 is @nogc yet allocates closures with the GC 8 fail_compilation/diag12829.d(31): diag12829.test2.S.foo closes over variable x at fail_compilation/diag12829.d(28) 9 --- 10 */ 11 test1()12auto test1() @nogc 13 { 14 int x; 15 void delegate() @nogc foo = () { 16 int y = x; 17 }; 18 19 void bar() 20 { 21 int y = x; 22 } 23 auto dg = &bar; 24 } 25 test2()26auto test2() @nogc 27 { 28 int x; 29 struct S 30 { 31 void foo() 32 { 33 int y = x; 34 } 35 } 36 return S(); 37 } 38