Purity and enum

simendsjo simendsjo at gmail.com
Mon Feb 6 02:21:03 PST 2012


Not sure if this is a bug, or just some missing functionality of pure.

void f() pure {
   enum a = to!string("a"); // some legal compile-time to!()
}

Gives "to is not pure"

The following works:

template S(alias v) {
   enum S = to!string(v);
}
void g() pure {
   enum a = S!"a";
}

Should purity be checked at all if used with an enum?

Tested on dmd 2.057 / linux x64


More information about the Digitalmars-d-learn mailing list