Error with associative array initializer DMD32 D Compiler v2.070.0

asdf via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 3 02:44:27 PST 2016


On Thursday, 3 March 2016 at 10:35:50 UTC, MGW wrote:
> The citation from https://dlang.org/spec/hash-map.html
>
> Static Initialization of AAs
> ----------------------------
>
> immutable long[string] aa = [
>   "foo": 5,
>   "bar": 10,
>   "baz": 2000
> ];
>
> unittest
> {
>     assert(aa["foo"] == 5);
>     assert(aa["bar"] == 10);
>     assert(aa["baz"] == 2000);
> }
>
> Judging by the text, it is static initialization, during 
> compilation.

Hey your right! https://dlang.org/spec/hash-map.html

I don't actually understand D that much but runtime logic made 
sense...

That unit test passes somehow, perhaps because unit test are 
executed? Looks like a bug in the test and/or documentation!


More information about the Digitalmars-d-learn mailing list