Can someone please explain this behaviour? I find it totally bizarre.

auto f(T)(T x) {
        struct S {
                T y;
                this(int) { }
        }
        return S(0);
}


void main() {
        f(f(0));
}

Error: constructor f376.f!(S).f.S.this field y must be initialized in constructor, because it is nested struct

Why must y be initialized in the constructor? It isn't const. Why isn't it default initialized?

Is this explained anywhere in the docs? I can't see anything in the nested struct section, or in any constructor section.

Reply via email to