Trying to foreach through an AA[SA] generates a compiler error: import std.stdio; import std.md5; int main(char[][] args) { int[ubyte[16]] md5count; foreach (md5, count; md5count) writefln("%s: %d", std.md5.digestToString(md5), count); return 0; } Both gdc and dmd bail out on the foreach statement with: "test.d(5): Error: cannot have out or ref parameter of type ubyte[16u]" Possible workarounds: * use a wrapper struct for the static array (looks ugly) * use foreach (md5; md5count.keys) ... count = md5count[md5] (decreases performance almost by 50%)
i bet the code actually meant as following: mtype.c (2790): if (arg->storageClass & (STCout | STCref | STClazy)) { --- if (t->ty == Tsarray) +++ if (t->ty != Tsarray) error(loc, "cannot have out or ref parameter of type %s", t->toChars()); } I hand-crafted a dmd which bypass this check, it can generate correct binary.
umm, the patch is incorrect.. bypassing the whole test should work. /* if (arg->storageClass & (STCout | STCref | STClazy)) { if (t->ty == Tsarray) if (t->ty != Tsarray) error(loc, "cannot have out or ref parameter of type %s", t->toChars()); } */
I think this bug is now fixed, because fixed-sized arrays are managed by value.