1

In an e file, it's perfectly legal to say:

print 5;

But at the same time, the following thing doesn't work:

type some_type_e : [ VAL1, VAL2 ];
print VAL2;  // issues a compile error

The parser expects VAL2 to be a variable name and doesn't interpret it as a constant.

At the same time, this is allowed:

var some_int : int = 10;
if some_int != 5 {
  print "Some int not 5"
};

var some_enum : some_type_e = VAL1;
if some_enum != VAL2 {
  print "Some enum not VAL2";
};

In this case, VAL2 is interpreted as a constant.

The (simplified) syntax for print is print <exp>. Is an enum literal not an expression?

Tudor Timi
  • 7,453
  • 1
  • 24
  • 53
  • A colleague suggested that I try scoping VAL2 with its type, but I don't know how. What I've tried is `some_type_e::VAL2` and `some_type_e.VAL2`. – Tudor Timi Jul 03 '14 at 10:04

1 Answers1

1

I've figured it out. VAL2 on its own is meaningless as a constant. It has to be qualified with the type name. The proper way to do it is:

print some_type_e'VAL2;
Tudor Timi
  • 7,453
  • 1
  • 24
  • 53