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

20 lines
440 B
D

/* REQUIRED_ARGS: -preview=dip1000
TEST_OUTPUT:
---
fail_compilation/fail21868b.d(19): Error: escaping a reference to parameter `s` by returning `&s.x` is not allowed in a `@safe` function
fail_compilation/fail21868b.d(17): perhaps change the `return scope` into `scope return`
---
*/
// https://issues.dlang.org/show_bug.cgi?id=21868
struct S
{
int x;
int* y;
}
int* test(ref return scope S s) @safe
{
return &s.x;
}