Bug 4281 – AA literal problem with mutable array as key

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-06-06T05:03:00Z
Last change time
2015-06-09T05:11:48Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Attachments

IDFilenameSummaryContent-TypeSize
656patch1.diffmind a bit more lookahead?text/plain1271

Comments

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.