The following fails to compile: bool flag() { bool left, right; return true ? cast(const bool)left : cast(bool)right; } with the error "cannot implicitly convert expression (cast(int)left) of type int to bool". It seems to happen whenever the left and right sides differ in const-ness or invariant-ness. This becomes an issue when trying to write const-correct class functions which return bool, for example: class C { private int mask; private bool readyYet() const {return true;} public bool ExtractStateBit() const { return readyYet() ? (mask & 1) : false; } }
Fixed DMD2.031.