blob: 72826352af2098b3038012f63ecdb120e3310bc6 [file] [log] [blame]
/*
REQUIRED_ARGS: -preview=dip1000
TEST_OUTPUT:
---
fail_compilation/test20881.d(27): Error: address of variable `s` assigned to `global` with longer lifetime
fail_compilation/test20881.d(28): Error: address of variable `s` assigned to `global` with longer lifetime
fail_compilation/test20881.d(29): Error: address of variable `s` assigned to `global` with longer lifetime
---
*/
@safe:
// https://issues.dlang.org/show_bug.cgi?id=20881
struct S
{
int* ptr;
auto borrowA() return /*scope inferred*/ { return ptr; }
int* borrowB() return { return ptr; }
int* borrowC() scope return { return ptr; }
}
void main()
{
static int* global;
S s;
global = s.borrowA;
global = s.borrowB;
global = s.borrowC;
}