As described in this thread http://forum.dlang.org/post/qqouzioewrakuhpoeysy@forum.dlang.org iteration on associative arrays and certain features that use iteration, like getting the length, require a deep cast away of const. Part of the reason is the keys are copied. This is probably unnecessary and a better approach would be to have foreach(k,v;aa) assume that k is a ref const(K).
As far as I can tell... *** This issue has been marked as a duplicate of issue 9212 ***