On Sunday, May 27, 2012 21:45:22 bearophile wrote: > In some code I have created a small bug that can be reduced to > something like this, that the D compiler has not caught at > compile-time: > > > enum E1 { A, B } > enum E2 { C, D } > void main() { > E1[2] a; > with (E2) > assert(a[0] == D); > } > > > Why isn't D able to statically tell when you compare values of > different enums? > How much work is implementing this compile-time test inside the D > front-end?
If assert(E1.A == E2.D) wouldn't compile, then this is clearly a bug with with. If assert(E1.A == E2.d) compiles, then this behavior is clearly intended. My guess would be that this is a bug with with, but I don't think that I've ever tried to compare two different types of enums like that before, so I'd have to check. - Jonathan M Davis