Initialization of structures must be guaranteed. You donβt want the struct construct to throw an exception by default. For this reason, D does not support default constructors in structures. Imagine if
MyStr s;
led to the exception being thrown. Instead, D provides its own default constructor, which initializes all fields for the init property. In your case, you do not call your constructor and simply use the provided default values, which means that frontArr is never initialized. You want something like:
void main() { MyStr s = MyStr(10); s.push(5); }
The compiler error should probably have default values ββfor all parameters of the constructor constructor. Bugzilla
source share