www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17357] New: DMD wrongly considers template instance class as

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

          Issue ID: 17357
           Summary: DMD wrongly considers template instance class as
                    nested
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: puneet coverify.org

When compiled with github HEAD, I get:
test.d(6): Error: outer class Foo 'this' needed to 'new' nested class Frop
For now the workaround is to declare Frop static.

// static
class Frop(alias t) { }

void build(G)(G g) {
  alias E = typeof(g.tupleof[0]);
  g.tupleof[0] = new E;
}

class Tx {
  class Foo  {
    Frop!a cp_a;
    int a;
  }
  Foo bar;
  this() { bar = new Foo; }
}

void main() {
  Tx tx ;
  tx = new Tx;
  tx.bar.build;
}

--
Apr 28