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

27 lines
656 B
D

/* REQUIRED_ARGS: -preview=dip1000
* TEST_OUTPUT:
---
fail_compilation/fail17842.d(14): Error: assigning scope variable `p` to non-scope `*q` is not allowed in a `@safe` function
fail_compilation/fail17842.d(23): Error: copying scope variable `obj` into allocated memory is not allowed in a `@safe` function
---
*/
// https://issues.dlang.org/show_bug.cgi?id=17842
void* testp(scope void* p) @safe
{
scope void** q;
*q = p; // error
void** t;
*t = *q;
return *t;
}
Object testobj(scope Object obj) @safe
{
scope Object[] arr;
arr ~= obj; // error
Object[] array;
array ~= arr;
return array[0];
}