Array of associative array.

Ali Çehreli acehreli at yahoo.com
Mon Oct 28 15:13:46 PDT 2013


On 10/28/2013 02:39 PM, Wolftein wrote:

 >>> Error: variable org.ghrum.installer.option.CompilerTable cannot
 >>> infer type from initializer
 >>
 >> The declaration is public static auto CompilerTable = [ ... ]
 >
 > Had to use string[string][] instead of auto.

Looks like a compiler bug to me. Reduced:

void foo(T)(T)
{
     pragma(msg, T.stringof);
}

void main()
{
     // Works and prints string[string][]
     pragma(msg, typeof([ [ "a" : "a"] ]).stringof);

     // Works and prints string[string][]
     foo([ [ "a" : "a"] ]);

     // However, this fails
     auto a = [ [ "a" : "a"] ];
}

Is there a reason why the last line cannot be compiled?

Ali



More information about the Digitalmars-d-learn mailing list