Thread overview
[Issue 16763] Associative array literal inside array or AA literal doesn't work as initializer if variable type is known
Dec 16, 2016
Denis Shelomovskii
Dec 17, 2022
Iain Buclaw
Jul 01
Dlang Bot
December 16, 2016
https://issues.dlang.org/show_bug.cgi?id=16763

--- Comment #1 from Denis Shelomovskii <verylonglogin.reg@gmail.com> ---
(In reply to Denis Shelomovskii from comment #0)
>     int[int][] b = [[0 : 2]]; // expression ([[1]]) of type int[][]

It was "expression ([[2]])" actually.

So, looks like if `ArrayInitializer.inferType` isn't called AA literals are treated as array literals with explicit indices (see Static Initialization of Statically Allocated Arrays [1]) like in this code:
---
import std.stdio;

void main()
{
    int[][] a = [[2: 6, 1: 345, 3: 78, 6: 12]];
    writeln(a);
    int[][] aa = [1: [5: 7], 0: [7], 0: [0: 15] /* overrides previous element
0*/, [2: 6, 1: 3], /* overrides previous element 1*/ ];
    writeln(aa);
}
---
[[0, 345, 6, 78, 0, 0, 12]]
[[15], [0, 3, 6]]
---


[1] http://dlang.org/spec/arrays.html#static-init-static

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=16763

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--
July 01
https://issues.dlang.org/show_bug.cgi?id=16763

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> ---
@ntrel created dlang/dmd pull request #16644 "Fix Bugzilla 16763 - Associative array literal inside array or AA lit…" fixing this issue:

- Fix Bugzilla 16763 - Associative array literal inside array or AA literal doesn't work as initializer if variable type is known

https://github.com/dlang/dmd/pull/16644

--