www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13119] New: `struct` constructor attributes inferred like

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 puremagic.com
          Reporter: verylonglogin.reg 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- nogc function
'main.S.~this'
---

Note there is no errors for `nothrow` attribute.

--
Jul 13 2014