Why:

enum Base {
    A,
    B,
}

enum Derived : Base {
C, // Gives error, says it can't implicitly convert expression to Base.
    D = 1, // Same error
E = cast(Base)294, // Finally works. Can only be cast(Derived) instead.
}

void func(Derived d) {}

func(Derived.E); // works.
func(Derived.A); // Gives error, says it can't call function with Base.A.
func(cast(Derived)Derived.A); // Works.

So, what's the proper way of extending an enum?


Reply via email to