Enumeration compiles, but should it?

Hi,

I just came across this in a project and was surprised to see it compiling successfully (Elements 10.0.0.2485)

image

The enumeration is defined as :-

type SAMDataDestination = public enum(Standard=0, Actual=1, Budget=2, CreditNote=3, Rebate=4, InvoiceBlock=5, Peg39=6,Peg66=7, Peg93=8);

Is SAMDataDestination.Actual.Budget valid syntax ?

Sort of, yes. an enum is a type, and each enum value exposed as a static member on that type, and is also an instance of that type (ie SAMDataDestination.Actual is an instance of SAMDataDestination). Oxygene lets you access static members of a type even on a concrete instance, so that’s why you see all the values, on there value, too.

I wonder if we should limit CC to not show them though…

Thanks Marc ,

I think I understand the explanation. Not sure I’d understand when I’d ever make valid use of it though. To save a future head scratch, I’ve changed the code to the the simple form of SAMDataDestination.Budget

Not in case of enums, no. its more of a side effect.

but think

type
  Foo = public class
  public 
    class method Bar;
  end;

...

var f := new Foo;
f.Bar;

Thanks, logged as bugs://84128

bugs://E24014 was closed as fixed.