https://issues.dlang.org/show_bug.cgi?id=22434
Issue ID: 22434
Summary: Nested struct or not nested struct?
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
struct Storage(T) {
T[1] items;
this(T[] arr) { // Error: field `items` must be initialized in
constructor, because it is nested struct
/* ... */
}
}
void test() {
struct Cat {
~this() {} // nested
}
struct Box {
Cat cat;
}
//static assert(__traits(isNested, Box)); // would fail if uncommented
Storage!Box storage;
}
---
Cat is nested. Box contains Cat, has no explicitly defined methods, but does
have __xdtor due to Cat. Does not appear as a nested struct through __traits,
but stumps Storage's ctor "because it is nested struct".
--