| 1 |
/* REQUIRED_ARGS: -betterC |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/test23112.d(106): Error: function `test23112.bar` is `@nogc` yet allocates closure for `bar()` with the GC |
| 5 |
fail_compilation/test23112.d(108): function `f` closes over variable `a` |
| 6 |
fail_compilation/test23112.d(106): `a` declared here |
| 7 |
--- |
| 8 |
*/ |
| 9 |
|
| 10 |
// https://issues.dlang.org/show_bug.cgi?id=23112 |
| 11 |
|
| 12 |
#line 100 |
| 13 |
|
| 14 |
struct Forward(alias F) |
| 15 |
{ |
| 16 |
auto call()() { return F(); } |
| 17 |
} |
| 18 |
|
| 19 |
auto bar(int a) nothrow @safe |
| 20 |
{ |
| 21 |
auto f() |
| 22 |
{ |
| 23 |
return a; |
| 24 |
} |
| 25 |
return Forward!f(); |
| 26 |
} |
| 27 |
|
| 28 |
extern(C) void main() |
| 29 |
{ |
| 30 |
assert(bar(3).call() == 3); |
| 31 |
} |