struct S { @disable this(); bool cted; this(int x) { cted = true; } void foo() { assert(cted); } } class A { S s; this(int x) { s = S(1); } } class B : A { this() { s.foo(); // shouldn't compile super(1); } } void main() { auto b = new B; } The base class constructor should have been called before the struct can be accessed in the subclass.
The struct is in a valid state
-1 to me. It is however a language change to disallow this I think.
(In reply to mhh from comment #1) > The struct is in a valid state How is that? The default constructor is explicitly disabled to tell the compiler that the init state is *not valid* for that struct type (it is even dubbed "best practice" by p.6 of https://dlang.org/spec/struct.html#field-init).
The invalid state thing was me misreading the test case, apologies. I have brought up some kind of substrctural types in a meting so who knows if this behaviour may one day be properly fixed.