I have the following types (simplified version of my code):
struct A
{
int[] i;
}
struct B
{
A[] a = [A.init];
}
This code:
auto b1 = B.init;
b1.a[0].i ~= 1;
b1.a ~= A.init;
b1.a[0].i ~= 11;
b1.a[1].i ~= 12;
b1.writeln;
auto b2 = B();
b2.writeln;
prints this as expected:
B([A([1, 11]), A([12])])
B([A([])])
But this code:
B b1; // auto b1 = B.init;
b1.a[0].i ~= 1;
b1.a ~= A.init;
b1.a[0].i ~= 11;
b1.a[1].i ~= 12;
b1.writeln;
B b2; // auto b2 = B();
b2.writeln;
prints this which is not expected:
B([A([1, 11]), A([12])])
B([A([1])])
Does the second piece of code shows a bug or my expectation is not correct (and why if so)?