What is the state and plans on type-safety of enums in D?

I expected

import std.stdio: writeln;

void main(string args[]) {
    enum E {x, y, z}
    E e;
    writeln(e);
    e = cast(E)3;
    writeln(e);
}

to fail to compile because of D's otherwise strong static type/range checking or at least give an RangeException when run.

To my surprise, it instead prints

cast(E)3

Is this really the preferred default behaviour for the majority of use cases?

Reply via email to