That's why, in C we have:
if (a = b)
and: if (a < b < c)
that cause (in some compilers) warnings. I wanted to make this an error in D. One option is to check for and disallow them after the parse, but that left: if ((a < b) < c)
as still an error. I wanted to allow these constructs to remain if they were parenthesized, as that would imply they were deliberate. (Yes, parenthesized expressions could be a separate grammar, but I thought that was an awful idea.)The solution is to fix the grammar, so they wouldn't even parse. The beauty of this is one doesn't have to enable warnings, or have a separate check for them, it just won't compile. Even better, D's expression grammar is the same as C's, and it did not upset anything else in the grammar as a side effect.
Based on my experience at Boeing designing hardware, defining the problem out of existence is a great way to design robust systems.