| 1 |
// REQUIRED_ARGS: -o- |
| 2 |
/* |
| 3 |
TEST_OUTPUT: |
| 4 |
--- |
| 5 |
fail_compilation/diag15411.d(17): Error: function `diag15411.test15411.__funcliteral_L17_C15` cannot access variable `i` in frame of function `diag15411.test15411` |
| 6 |
fail_compilation/diag15411.d(16): `i` declared here |
| 7 |
fail_compilation/diag15411.d(18): Error: function `diag15411.test15411.__funcliteral_L18_C15` cannot access variable `i` in frame of function `diag15411.test15411` |
| 8 |
fail_compilation/diag15411.d(16): `i` declared here |
| 9 |
fail_compilation/diag15411.d(26): Error: `static` function `diag15411.testNestedFunction.myFunc2` cannot access function `myFunc1` in frame of function `diag15411.testNestedFunction` |
| 10 |
fail_compilation/diag15411.d(25): `myFunc1` declared here |
| 11 |
--- |
| 12 |
*/ |
| 13 |
|
| 14 |
void test15411() |
| 15 |
{ |
| 16 |
auto i = 0; |
| 17 |
auto j = (function() { return i; })(); |
| 18 |
auto f = function() { return i; }; |
| 19 |
} |
| 20 |
|
| 21 |
void testNestedFunction () |
| 22 |
{ |
| 23 |
int i = 42; |
| 24 |
|
| 25 |
void myFunc1() { assert(i == 42); } |
| 26 |
static void myFunc2 () { myFunc1(); } |
| 27 |
} |