dmd/compiler/test/fail_compilation/test17423.d
Dennis 9b94878c85
Make safe error messages consistent (#20654)
Co-authored-by: Dennis Korpel <dennis@sarc.nl>
2025-01-08 13:46:38 +08:00

30 lines
635 B
D

/* REQUIRED_ARGS: -preview=dip1000
TEST_OUTPUT:
---
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
fail_compilation/test17423.d(16): which is not `scope` because of `this.myDlg = dlg`
---
*/
// https://issues.dlang.org/show_bug.cgi?id=17423
struct Bar
{
int delegate(int) @safe myDlg;
auto opApply(int delegate(int) @safe dlg) @safe {
myDlg = dlg;
return 0;
}
}
struct Foo
{
Bar o;
int i = 3;
this(int x) @safe {
foreach(_; o) { i = 0; }
i = x;
}
}