www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13564] New: nested struct destructor trying to access members

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

          Issue ID: 13564
           Summary: nested struct destructor trying to access members of a
                    global class fail to compile
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: ace17 free.fr

The following code used to compile, but doesn't anymore:

class Element(T)
{
  int pos;
}

class Container(T)
{
  struct Structure
  {
    ~this()
    {
      Container!int c;
      c.element.pos = 0;
    }
  }

  Element!T element;
}

void f()
{
  new Container!int ();
}

ace ANTEC /tmp % dmd yo.d 
yo.d(13): Error: no property 'pos' for type 'Element!int'
yo.d(22): Error: template instance yo.Container!int error instantiating

It doesn't occur if "Structure" is moved out of "Container".
It doesn't occur if the destructor is replaced by a regular function.

Is this normal?

--
Oct 01 2014