Inferred enum base types

Lennart Blanco cokebuttle at
Fri Oct 14 11:47:12 PDT 2011


When compiling following code with dmd (v2.051)

enum nums {  X = 'a', Y, Z }

void main() {
  nums q;
  char w;
  w = q;

I get 'Error: cannot implicitly convert expression (q) of type nums to char'
for the 'w = q' assigment.

Should'n the inferred base type for 'nums' be char, given that the first
'nums' member is initilized with char literal 'a'?

When the nums declaration is changed to:

enum nums : char {  X = 'a', Y, Z }

the code compiles without errors.

It seems that when enums base type is allways inferred to int. Am I missing
something or is it an DMD bug?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Digitalmars-d mailing list