Documentation wrong. Bug? Old functionality?

simendsjo simen.endsjo at pandavre.com
Sun Apr 3 05:42:50 PDT 2011


This is from the array documentation

enum Color { red, blue, green };
int value[Color.max + 1] = [ Color.blue:6, Color.green:2, Color.red:5 ];

It gives the following errors on dmd 2.052 on windows:

Error: Integer constant expression expected instead of Color.blue
Error: Integer constant expression expected instead of Color.green
Error: Integer constant expression expected instead of Color.red
Error: Integer constant expression expected instead of Color.blue
Error: Integer constant expression expected instead of Color.green
Error: Integer constant expression expected instead of Color.red

Even if I set the enum elements manually the same errors occur. Seems constant enough for
me though..

The following works
int value[Color.max + 1] = [ 1:6, 2:2, 0:5 ];


More information about the Digitalmars-d-learn mailing list