gcc/testsuite/gdc.test/compilable/test20596.d
raw| 1 | // PERMUTE_ARGS: -preview=dip1000 |
| 2 | |
| 3 | // https://issues.dlang.org/show_bug.cgi?id=20596 |
| 4 | |
| 5 | struct S(T) |
| 6 | { |
| 7 | void delegate() dg; |
| 8 | |
| 9 | this(scope void delegate() dg) |
| 10 | { |
| 11 | this.dg = dg; |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | @nogc void fooTemplate() |
| 16 | { |
| 17 | int num; |
| 18 | |
| 19 | void foo() { int dummy = num; } |
| 20 | |
| 21 | scope s = S!int(&foo); |
| 22 | } |
| 23 | |
| 24 | void test3032() @nogc |
| 25 | { |
| 26 | int n = 1; |
| 27 | scope fp = (){ n = 10; }; // no closure |
| 28 | fp(); |
| 29 | } |