[Issue 13119] New: `struct` constructor attributes inferred like field destructor is called on initialization

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Jul 13 01:27:40 PDT 2014


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: nobody at puremagic.com
          Reporter: verylonglogin.reg at gmail.com

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- at nogc function
'main.S.~this'
---

Note there is no errors for `nothrow` attribute.

--


More information about the Digitalmars-d-bugs mailing list