Inferred enum base types

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


Hi

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?

/lennart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20111014/a786d0d4/attachment.html>


More information about the Digitalmars-d mailing list