| 1 |
/+ |
| 2 |
REQUIRED_ARGS: -preview=dip1000 |
| 3 |
TEST_OUTPUT: |
| 4 |
--- |
| 5 |
fail_compilation/fail24212.d(29): Error: assigning reference to local variable `n` to non-scope parameter `p` calling `fun` is not allowed in a `@safe` function |
| 6 |
--- |
| 7 |
+/ |
| 8 |
class Base |
| 9 |
{ |
| 10 |
@safe pure nothrow |
| 11 |
void fun(int* p) {} |
| 12 |
} |
| 13 |
|
| 14 |
void test() @safe |
| 15 |
{ |
| 16 |
int* escaped; |
| 17 |
|
| 18 |
class Escaper : Base |
| 19 |
{ |
| 20 |
@safe pure nothrow |
| 21 |
override void fun(int* p) |
| 22 |
{ |
| 23 |
escaped = p; |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
int n; |
| 28 |
Base base = new Escaper; |
| 29 |
base.fun(&n); |
| 30 |
} |