[Issue 22434] New: Nested struct or not nested struct?
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Oct 25 14:00:53 UTC 2021
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: nobody at puremagic.com
Reporter: stanislav.blinov at gmail.com
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".
--
More information about the Digitalmars-d-bugs
mailing list