[Issue 22910] New: [dip1000] return scope struct member functions allow returning `this` by ref

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 22 15:13:33 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=22910

          Issue ID: 22910
           Summary: [dip1000] return scope struct member functions allow
                    returning `this` by ref
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: safe
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dkorpel at live.nl

This should give an error since the function is `return scope`, while it should
be `return ref` for returning a reference to `this`:
```
struct S
{
    int  val;
    int* ptr;

    int* retScope() return scope
    {
        return &this.val;
    }
}
```

--


More information about the Digitalmars-d-bugs mailing list