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

          Issue ID: 13119
           Summary: `struct` constructor attributes inferred like field
                    destructor is called on initialization
           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]

This code should compile:
---
struct S
{
    this(int) @safe pure nothrow @nogc { }
    ~this() { }
}

struct T
{
    S s;

    this(int) @safe pure nothrow @nogc
    {
        s = S(0); // line 13
    }
}
---
main.d(13): Error: pure function 'main.T.this' cannot call impure function
'main.S.~this'
main.d(13): Error: safe function 'main.T.this' cannot call system function
'main.S.~this'
main.d(13): Error: @nogc function 'main.T.this' cannot call non-@nogc function
'main.S.~this'
---

Note there is no errors for `nothrow` attribute.

--

Reply via email to