www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17267] New: Forward reference error in recursive template

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

          Issue ID: 17267
           Summary: Forward reference error in recursive template
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: japplegame gmail.com

This code compiles:
struct A(T) {
    T* ptr;
    void m() {
        pragma(msg, T.sizeof);
    }
}

struct B {
    int i;
    A!B a;
}

Following should compile, but doesn't (struct foo.B no size because of forward
reference):

// example 1 (struct definition inside function)
struct A(T) {
    T* ptr;
    void m() {
        pragma(msg, T.sizeof);
    }
}

void foo() {
    static struct B {
        int i;
        A!B a;
    }
}

// example 2 (sizeof outside member function)
struct A(T) {
    T* ptr;
    pragma(msg, T.sizeof);
}

struct B {
    int i;
    A!B a;
}

--
Mar 19