https://issues.dlang.org/show_bug.cgi?id=23375
--- Comment #2 from Bolpat <[email protected]> --- As enum was intended to be a replacement of C’s `#define` constants, the compiler should thoroughly treat `enum` as a named literal; it can support “mutable” indirections, but a lot more has to be taken. By “mutable” I mean typed non-const, not that actual mutation is valid. An easy way would be to specify that enums are deep-copied at usage site. This might be possible because circular definitions are rejected: class C { C bestie; this() { } this(C friend) { bestie = friend; } } enum C me = new C(you); enum C you = new C(me); // error enum C[] us = [ me, you ]; But you can cheese it: enum C[] us = [ new C, new C ]; shared static this() { us[0].bestie = us[1]; us[1].bestie = us[0]; } void main() { assert(us[0].bestie is us[1]); assert(us[1].bestie is us[0]); assert(us[0].bestie.bestie is us[0]); assert(us[1].bestie.bestie is us[1]); } --
