www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Bug? enum inside class limited to integral values

I don't know if its a bug or intended behavior, the documentation doesn't
mention this.

Enums in the global scope can allow any type for declarations:
enum {
    FOO = 1, BAR = "foobar"

However, when using the same syntax within a class, the compiler spits out a
nasty Error: Integer constant expression expected instead of "foobar". When
using the enum as a manifest constant, (enum BAR = "foobar";) it works just

If this behavior is intentional, may I ask why? I fail to assume a rationale
behind having different behaviors from global scope to class scope for this.
Apr 27 2009