www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22017] New: with() on struct method that returns this


          Issue ID: 22017
           Summary: with() on struct method that returns this destroys too
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

Consider the following code:

struct S {
    bool destroyed;
    ~this() { destroyed = true; }
    ref S foo() return { return this; }

void main() {
    with (S().foo) {

Even if the with() expression is copied, the copied version should not see the
results of the destructor call. However, the assert fails.

Jun 11 2021