| 1 |
/* |
| 2 |
REQUIRED_ARGS: -preview=dip1000 |
| 3 |
TEST_OUTPUT: |
| 4 |
--- |
| 5 |
fail_compilation/fail22366.d(22): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function |
| 6 |
fail_compilation/fail22366.d(25): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function |
| 7 |
fail_compilation/fail22366.d(26): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function |
| 8 |
fail_compilation/fail22366.d(27): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function |
| 9 |
fail_compilation/fail22366.d(28): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function |
| 10 |
fail_compilation/fail22366.d(31): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function |
| 11 |
fail_compilation/fail22366.d(32): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function |
| 12 |
--- |
| 13 |
*/ |
| 14 |
|
| 15 |
// Test escaping scope variables through AA keys / values |
| 16 |
// https://issues.dlang.org/show_bug.cgi?id=22366 |
| 17 |
// https://issues.dlang.org/show_bug.cgi?id=23531 |
| 18 |
|
| 19 |
void fun(scope string s) @safe |
| 20 |
{ |
| 21 |
int[string] aa; |
| 22 |
aa[s] ^^= 3; |
| 23 |
|
| 24 |
string[string] saa; |
| 25 |
saa[""] = s; |
| 26 |
saa[""] ~= s; |
| 27 |
saa[s] = ""; |
| 28 |
saa[s] ~= ""; |
| 29 |
|
| 30 |
string[string][string] snaa; |
| 31 |
snaa[s][""] = ""; |
| 32 |
snaa[""][s] = ""; |
| 33 |
} |