no size yet for forward reference error

Erik Smith via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 24 16:50:18 PST 2016


In the process of converting my working database interface to be 
template based, I now get the following compiler error:

Error: struct 
std.database.mock.database.Statement!int.Statement.Payload no 
size yet for forward reference

I minimized the code to make it easier reason about.  It seems to 
have something to do with Payload, but it may also have something 
to do with the ResultRange / Row circular references.

The error is reported in object.d(2762,45).  This is DMD v2.070.

Any Ideas?


unittest {
     auto db = Database!int.create();
     auto con = Connection!int(db);
}

struct Database(T) {
     static Database create() { return Database!T();}
}

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

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

     private:

     struct Payload {
         Connection con;
         this(Connection con_) {con = con_;}
         this(this) { assert(false); }
         void opAssign(Statement.Payload rhs) { assert(false); }
     }

     alias RefCounted!(Payload, RefCountedAutoInitialize.no) Data;
     Data data_;
}

struct Result(T) {
     alias Statement = .Statement!T;
     alias ResultRange = .ResultRange!T;
     alias Range = .ResultRange;
     alias Row = .Row;

     this(Statement stmt) {data_ = Data(stmt);}
     ResultRange range() {return ResultRange(this);}
}

struct ResultRange(T) {
     alias Result = .Result!T;
     alias Row = .Row!T;
     private Result result_;
     this(Result result) {result_ = result;}
}


struct Row(T) {
     alias Result = .Result!T;
     this(Result* result) { result_ = result;}
     private Result* result_;
}



More information about the Digitalmars-d mailing list