www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22967] New: [dip1000] no return ref inference for extended


          Issue ID: 22967
           Summary: [dip1000] no return ref inference for extended return
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dkorpel live.nl

When returning a parameter by assignment to the first ref parameter, return
scope can be inferred when it's a template/auto function. This is not the case
for return ref yet:
struct S()
    int* x;
    this(scope int* x) { this.x = x; } // return scope inferred
    this(ref int x) { this.x = &x; } // no return ref inferred, error

void main()
    S!() s;

Apr 02 2022