Bug 12787 – can't nest associative arrays and arrays
Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-05-22T18:51:00Z
Last change time
2014-06-19T04:19:35Z
Keywords
rejects-valid
Assigned to
nobody
Creator
vlevenfeld
Comments
Comment #0 by vlevenfeld — 2014-05-22T18:51:43Z
this code will fail to compile at the declaration of a2, with Error: not an associative array initializer
int[][char][][] a1 = [
[
['a':[1,2,3],'b':[2,3,4],'c':[3,4,5]],
['d':[6,7,8],'e':[7,8,9]]
],
[
['a':[1,2,3],'b':[2,3,4],'c':[3,4,5]],
['d':[6,7,8],'e':[7,8,9]]
]
];
int[][char][][int] a2 = [
1000:[
['a':[1,2,3],'b':[2,3,4],'c':[3,4,5]],
['d':[6,7,8],'e':[7,8,9]]
],
2000:[
['a':[1,2,3],'b':[2,3,4],'c':[3,4,5]],
['d':[6,7,8],'e':[7,8,9]]
]
];
Comment #1 by bearophile_hugs — 2014-05-22T19:39:06Z
Probably this is already reported in another Bugzilla issue.
This is a workaround until this problem gets fixed:
void main() {
int[][char][][] a1 = [
[
['a':[1,2,3],'b':[2,3,4],'c':[3,4,5]],
['d':[6,7,8],'e':[7,8,9]]
],
[
['a':[1,2,3],'b':[2,3,4],'c':[3,4,5]],
['d':[6,7,8],'e':[7,8,9]]
]
];
int[][char][][int] a2 = cast()[
1000:[
['a':[1,2,3],'b':[2,3,4],'c':[3,4,5]],
['d':[6,7,8],'e':[7,8,9]]
],
2000:[
['a':[1,2,3],'b':[2,3,4],'c':[3,4,5]],
['d':[6,7,8],'e':[7,8,9]]
]
];
}
Comment #2 by vlevenfeld — 2014-05-22T20:15:31Z
you rock!
Comment #3 by k.hara.pg — 2014-06-19T04:19:35Z
*** This issue has been marked as a duplicate of issue 6469 ***