www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15726] New: forward reference error for circular classes,


          Issue ID: 15726
           Summary: forward reference error for circular classes,
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: erik cruiserhouse.com

The code below fails to compile with the following error:

/usr/local/Cellar/dmd/2.070.1-b1_1/include/dlang/dmd/object.d(2762): Error:
struct bug.Statement!int.Statement.Payload no size yet for forward reference

It's an issue involving circular struct references and RefCounted (with a
reduced version below). Possible related issues: 12000, 14390

The failing PR found via digger:


Here is the failing code:

struct RefCounted(T) {
    struct Impl {
        T _payload;

    Impl* _store;

    ~this() {

struct Connection(T) {
    alias Statement = .Statement!T;

struct Statement(T) {
    alias Connection = .Connection!T;

    struct Payload {
        Connection con;

    RefCounted!Payload Data;

Connection!int x;

Feb 25 2016