dmd/compiler/test/fail_compilation/test22145.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

28 lines
481 B
D

/* TEST_OUTPUT:
REQUIRED_ARGS: -preview=dip1000
---
fail_compilation/test22145.d(115): Error: assigning scope variable `x` to global variable `global` is not allowed in a `@safe` function
---
*/
// issues.dlang.org/show_bug.cgi?id=22145
#line 100
struct S
{
int opApply (scope int delegate (scope int* ptr) @safe dg) @safe
{
return 0;
}
}
void test() @safe
{
static int* global;
S s;
foreach (scope int* x; s)
{
global = x;
}
}