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

          Issue ID: 14252
           Summary: Erroneous dtor attributes check even if the struct
                    returned immediately
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: [email protected]
          Reporter: [email protected]

Following code should work, but doesn't.

struct Variant
{
    this(int) pure {}
    ~this() {}  // impure
}

auto makeVar(int n) pure
{
    return Variant(1);    // line 9
}

void main()
{
    auto v = makeVar(1);
}

test.d(9): Error: pure function 'test.makeVar' cannot call impure function
'test.Variant.~this'

--

Reply via email to