www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14252] New: Erroneous dtor attributes check even if the

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: nobody puremagic.com
          Reporter: k.hara.pg gmail.com

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'

--
Mar 06 2015