Comment #0 by bearophile_hugs — 2010-06-06T05:03:25Z
This D2 code seems correct:
void main() {
int[int[]] aa = [[1]: 2];
}
But DMD v2.046 prints at compile-time:
test.d(2): comma expected separating array initializers, not :
test.d(2): semicolon expected, not '3'
test.d(2): found ']' when expecting ';' following 'statement'
See also Bug 4279
Comment #1 by ellery-newcomer — 2010-06-06T08:00:00Z
Created attachment 656
mind a bit more lookahead?
your code looks fine. dmd's parser doesn't honor the second line in
ArrayMemberInitialization:
NonVoidInitializer
AssignExpression : NonVoidInitializer
for array literals.
Comment #2 by andrej.mitrovich — 2012-10-21T13:25:31Z
It compiles now, although I'm not sure if such a key should be allowed..
Comment #3 by bearophile_hugs — 2012-10-21T13:51:00Z
(In reply to comment #2)
> It compiles now, although I'm not sure if such a key should be allowed..
The type of the key of this associative array is actually "const int[]", despite the type signature says something different... So the keys are OK. It's the associative array type signature that is not good.