void f(ref int i, ref string str, ref int[int] aa){ i = 2; str ~= "hello"; aa[1] = 2; assert(aa[1] == 2); } static assert({ int[int] aa; int i; string str; f(i, str, aa); assert(i == 2);// OK assert(str == "hello");// OK assert(aa[1] == 2);// Error: cannot index null array aa }()); The above code doesn't be compiled by the dmd v2.056 DEBUG built from github after the commit 42fea4c1f2. This means that ref argument of AA doesn't work well in CTFE.
This bug only applies in the case where the AA is null, at the moment when it is passed by reference.
https://github.com/D-Programming-Language/dmd/commit/51d83859ec2440f90ca1625640358502372b1465 https://github.com/D-Programming-Language/dmd/commit/411fdb0f7b391a028d40ec888b63d44ebcb646bb