This is a semantically wrong D2 program, the programmer has used a "&=" instead of "|=" to build a flag result: enum Flags { NONE = 0b00, FIRST = 0b01, SECOND = 0b10 } Flags foo(int x) { Flags result = Flags.NONE; if (x < 10) result |= Flags.FIRST; else result &= Flags.SECOND; // line 10 return result; } void main() {} The D compiler can find this problem in the code at line 10 because in that program the variable "result" is certantly zero after the assignment with Flags.SECOND, so it's an error or it's useless code.
So, if I understand correctly, you want the compiler to statically calculate results where all the inputs are known at compile-time and detect when no change has occurred in a "&=" (and presumably in other operator-assignment operators?) In such cases, should the compiler raise a warning or an error? This all fits in nicely with CTFE.
Walter has repeatedly stated that dmd-fe does not and will not do dataflow analysis. The problem with these sort of examples is that they seem trivial to implement for the simple cases, but once you start to think about more complex scenarios, the implementation becomes very complicated very fast. I will close this as WONTFIX.