www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22919] New: [dip1000] -checkaction=context gives "assigned to

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

          Issue ID: 22919
           Summary: [dip1000] -checkaction=context gives "assigned to
                    `__assertOp2` with longer lifetime"
           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

```
 safe:
struct S
{
    int* p;
    ref S get() scope return {return this;}
}

unittest
{
    int[3] sArr;
    scope S arr = S();
    assert(arr == arr.get());
}
```
Compile with:
 dmd -preview=dip1000 -checkaction=context test.d
Gives:
 scope variable `arr` assigned to `__assertOp2` with longer lifetime
--
Mar 24 2022