This code:
-----
import std.container.array;

struct Test {
        Array!Test t;
}
-----

Fails with an error:
-----
/usr/include/dlang/dmd/std/traits.d(2404): Error: struct arrayissue.Test no size because of forward reference /usr/include/dlang/dmd/std/traits.d(3462): Error: template instance std.traits.FieldTypeTuple!(Test) error instantiating /usr/include/dlang/dmd/std/container/array.d(276): instantiated from here: hasElaborateDestructor!(Test)
arrayissue.d(4):        instantiated from here: Array!(Test)
/usr/include/dlang/dmd/std/container/array.d(280): Error: template instance std.traits.hasIndirections!(Test) error instantiating
arrayissue.d(4):        instantiated from here: Array!(Test)
/usr/include/dlang/dmd/std/traits.d(2613): Error: template instance std.traits.RepresentationTypeTuple!(Test) error instantiating /usr/include/dlang/dmd/std/traits.d(2934): instantiated from here: hasRawAliasing!(Test) /usr/include/dlang/dmd/std/algorithm/mutation.d(1362): instantiated from here: hasAliasing!(Test) /usr/include/dlang/dmd/std/algorithm/mutation.d(1206): instantiated from here: moveEmplace!(Test) /usr/include/dlang/dmd/std/algorithm/mutation.d(1200): ... (3 instantiations, -v to show) ... /usr/include/dlang/dmd/std/container/array.d(487): instantiated from here: RangeT!(Array!(Test))
arrayissue.d(4):        instantiated from here: Array!(Test)
/usr/include/dlang/dmd/std/traits.d(2934): Error: template instance std.traits.hasObjects!(Test) error instantiating /usr/include/dlang/dmd/std/algorithm/mutation.d(1362): instantiated from here: hasAliasing!(Test) /usr/include/dlang/dmd/std/algorithm/mutation.d(1206): instantiated from here: moveEmplace!(Test) /usr/include/dlang/dmd/std/algorithm/mutation.d(1200): instantiated from here: moveImpl!(Test) /usr/include/dlang/dmd/std/algorithm/mutation.d(1162): ... (2 instantiations, -v to show) ... /usr/include/dlang/dmd/std/container/array.d(487): instantiated from here: RangeT!(Array!(Test))
arrayissue.d(4):        instantiated from here: Array!(Test)
/usr/include/dlang/dmd/std/algorithm/mutation.d(1372): Error: template instance std.traits.hasElaborateAssign!(Test) error instantiating /usr/include/dlang/dmd/std/algorithm/mutation.d(1206): instantiated from here: moveEmplace!(Test) /usr/include/dlang/dmd/std/algorithm/mutation.d(1200): instantiated from here: moveImpl!(Test) /usr/include/dlang/dmd/std/algorithm/mutation.d(1162): instantiated from here: trustedMoveImpl!(Test) /usr/include/dlang/dmd/std/container/array.d(148): ... (1 instantiations, -v to show) ... /usr/include/dlang/dmd/std/container/array.d(487): instantiated from here: RangeT!(Array!(Test))
arrayissue.d(4):        instantiated from here: Array!(Test)
/usr/include/dlang/dmd/std/algorithm/mutation.d(1379): Error: template instance std.traits.hasElaborateCopyConstructor!(Test) error instantiating /usr/include/dlang/dmd/std/algorithm/mutation.d(1206): instantiated from here: moveEmplace!(Test) /usr/include/dlang/dmd/std/algorithm/mutation.d(1200): instantiated from here: moveImpl!(Test) /usr/include/dlang/dmd/std/algorithm/mutation.d(1162): instantiated from here: trustedMoveImpl!(Test) /usr/include/dlang/dmd/std/container/array.d(148): ... (1 instantiations, -v to show) ... /usr/include/dlang/dmd/std/container/array.d(487): instantiated from here: RangeT!(Array!(Test))
arrayissue.d(4):        instantiated from here: Array!(Test)
-----

But if I use `Test[] t;` instead, everything is fine.

Also, same code with `class` instead of `struct` works fine, and using `union` produces this error message:
-----
/usr/include/dlang/dmd/std/traits.d(2404): Error: union arrayissue.Test no size because of forward reference /usr/include/dlang/dmd/std/traits.d(3025): Error: template instance std.traits.FieldTypeTuple!(Test) error instantiating /usr/include/dlang/dmd/std/container/array.d(280): instantiated from here: hasIndirections!(Test)
arrayissue.d(4):        instantiated from here: Array!(Test)
/usr/include/dlang/dmd/std/traits.d(2613): Error: template instance std.traits.RepresentationTypeTuple!(Test) error instantiating /usr/include/dlang/dmd/std/traits.d(2934): instantiated from here: hasRawAliasing!(Test) /usr/include/dlang/dmd/std/algorithm/mutation.d(1362): instantiated from here: hasAliasing!(Test) /usr/include/dlang/dmd/std/algorithm/mutation.d(1206): instantiated from here: moveEmplace!(Test) /usr/include/dlang/dmd/std/algorithm/mutation.d(1200): ... (3 instantiations, -v to show) ... /usr/include/dlang/dmd/std/container/array.d(487): instantiated from here: RangeT!(Array!(Test))
arrayissue.d(4):        instantiated from here: Array!(Test)
----


So, is it a bug, which should be fixed or it cannot be implemented at all? In this case it should be documented.

Reply via email to