| 1 |
/* REQUIRED_ARGS: -preview=dip1000 |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/test17423.d(27): Error: assigning reference to local `this` to non-scope parameter `dlg` calling `opApply` is not allowed in a `@safe` function |
| 5 |
fail_compilation/test17423.d(16): which is not `scope` because of `this.myDlg = dlg` |
| 6 |
--- |
| 7 |
*/ |
| 8 |
|
| 9 |
// https://issues.dlang.org/show_bug.cgi?id=17423 |
| 10 |
|
| 11 |
struct Bar |
| 12 |
{ |
| 13 |
int delegate(int) @safe myDlg; |
| 14 |
|
| 15 |
auto opApply(int delegate(int) @safe dlg) @safe { |
| 16 |
myDlg = dlg; |
| 17 |
return 0; |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
struct Foo |
| 22 |
{ |
| 23 |
Bar o; |
| 24 |
int i = 3; |
| 25 |
|
| 26 |
this(int x) @safe { |
| 27 |
foreach(_; o) { i = 0; } |
| 28 |
i = x; |
| 29 |
} |
| 30 |
} |