non-constant error for module AA"s

BlazingWhitester max.klyga at gmail.com
Mon Jan 24 14:45:26 PST 2011


On 2011-01-24 17:45:03 +0200, Andrej Mitrovic said:

> Is this a bug?
> 
> import std.stdio;
> 
> string[string] values = ["abc":"abc", "def":"def"];
> 
> void main()
> {
>     string[string] values2 = ["abc":"abc", "def":"def"];
> }
> 
> 
> test.d(3): Error: non-constant expression ["abc":"abc","def":"def"]
> 
> What's non-constant about that expression?

It's because of D's implementation of AA, but you can make it work with 
enum, e.g. enum string[string] values = ["abc":"abc", "def":"def"]; // 
works just fine at compile time



More information about the Digitalmars-d-learn mailing list