[Issue 22919] New: [dip1000] -checkaction=context gives "assigned to `__assertOp2` with longer lifetime"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 24 13:35:58 UTC 2022


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 at puremagic.com
          Reporter: dkorpel at 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

--


More information about the Digitalmars-d-bugs mailing list