| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/fail13120.d(13): Error: `pure` delegate `fail13120.g1.__foreachbody_L12_C5` cannot call impure function `fail13120.f1` |
| 5 |
fail_compilation/fail13120.d(13): Error: `@nogc` delegate `fail13120.g1.__foreachbody_L12_C5` cannot call non-@nogc function `fail13120.f1` |
| 6 |
--- |
| 7 |
*/ |
| 8 |
void f1() {} |
| 9 |
|
| 10 |
void g1(char[] s) pure @nogc |
| 11 |
{ |
| 12 |
foreach (dchar dc; s) |
| 13 |
f1(); |
| 14 |
} |
| 15 |
|
| 16 |
/* |
| 17 |
TEST_OUTPUT: |
| 18 |
--- |
| 19 |
fail_compilation/fail13120.d(35): Error: `pure` function `fail13120.h2` cannot call impure function `fail13120.g2!().g2` |
| 20 |
fail_compilation/fail13120.d(30): which calls `f2` |
| 21 |
fail_compilation/fail13120.d(35): Error: `@safe` function `fail13120.h2` cannot call `@system` function `fail13120.g2!().g2` |
| 22 |
fail_compilation/fail13120.d(27): `fail13120.g2!().g2` is declared here |
| 23 |
fail_compilation/fail13120.d(35): Error: `@nogc` function `fail13120.h2` cannot call non-@nogc function `fail13120.g2!().g2` |
| 24 |
--- |
| 25 |
*/ |
| 26 |
void f2() {} |
| 27 |
void g2()(char[] s) |
| 28 |
{ |
| 29 |
foreach (dchar dc; s) |
| 30 |
f2(); |
| 31 |
} |
| 32 |
|
| 33 |
void h2() @safe pure @nogc |
| 34 |
{ |
| 35 |
g2(null); |
| 36 |
} |