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:
https://github.com/D-Programming-Language/dmd/pull/4457
Here is the failing code:
struct RefCounted(T) {
struct Impl {
T _payload;
}
Impl* _store;
~this() {
destroy(_store._payload);
}
}
struct Connection(T) {
alias Statement = .Statement!T;
}
struct Statement(T) {
alias Connection = .Connection!T;
struct Payload {
Connection con;
}
RefCounted!Payload Data;
}
Connection!int x;
Comment #1 by erik — 2016-03-08T00:31:25Z
This bug also occurs in other cases where the types are not directly cross referenced with top level aliases (see example below using same RefCounted as in first example). This is blocking multiple design paths without a workaround.
struct Util(C,S) {}
struct Connection(T) {
alias Util = .Util!(Connection!T, Statement!T);
}
struct Statement(T) {
struct Payload {
Connection!T con;
}
RefCounted!Payload Data;
}
Connection!int x;