[Issue 22916] [dip1000] copy of ref return still treated as scope variable
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Oct 10 11:12:30 UTC 2022
    
    
  
https://issues.dlang.org/show_bug.cgi?id=22916
--- Comment #12 from Dennis <dkorpel at live.nl> ---
I've found a workaround for this issue by the way: convert the `ref` return to
a pointer and dereference that to get the non-scope value.
```
// compile with -preview=dip1000
@safe:
struct Arr
{
    int** ptr;
    ref int* index() return scope {
        return *ptr;
    }
    void assign(int* p) scope {
        *ptr = p;
    }
}
void main()
{
    scope Arr a;
    a.assign(*&a.index());
    auto tmp = &a.index();
    a.assign(*tmp);
}
```
--
    
    
More information about the Digitalmars-d-bugs
mailing list