| 1 |
// https://issues.dlang.org/show_bug.cgi?id=23168 |
| 2 |
// Issue 23168 - [DIP1000] return scope wrongly rewritten for structs with no indirections |
| 3 |
|
| 4 |
@safe: |
| 5 |
struct Ptr |
| 6 |
{ |
| 7 |
int* fun() return scope { return null; } |
| 8 |
} |
| 9 |
|
| 10 |
int* funf(ref return scope Ptr p) { return null; } |
| 11 |
|
| 12 |
int* use() |
| 13 |
{ |
| 14 |
Ptr ptr; |
| 15 |
return ptr.fun; |
| 16 |
return funf(ptr); |
| 17 |
} |
| 18 |
|
| 19 |
// Prevent forward reference 'regression' |
| 20 |
// See https://github.com/dlang/dmd/pull/14232#issuecomment-1162906573 |
| 21 |
struct S |
| 22 |
{ |
| 23 |
void f() scope {} |
| 24 |
alias x = _get_value; |
| 25 |
|
| 26 |
static if (true) |
| 27 |
int _get_value() {return 3;} |
| 28 |
else |
| 29 |
int _get_value() {return 4;} |
| 30 |
} |