www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23294] New: [dip1000] parameter to parameter assignment leads


          Issue ID: 23294
           Summary: [dip1000] parameter to parameter assignment leads to
                    incorrect scope inference
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: safe
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dkorpel live.nl

x and y are inferred scope in the following example:
int global;

auto f(int* x, int* y)
    x = y;
    global++; // make sure it's not inferring scope from pure

void g(scope int* z)
    f(z, z); // passes

When you mark `x` and `y` as `scope` explicitly, it errors:

 Error: scope variable `y` assigned to `x` with longer lifetime
But evidently, scope parameter inference does not care about relative lifetime of parameters, which is problematic when they have destructors. --
Aug 15 2022