The compiler can certainly implement checks that will work in trivial cases like this. But doing this is unlikely to help the very "real" code, since programmers rarely write such clearly incorrect code.
, . , , . , , , .
- . -, , , . -, ", X, , ", ", Y", , , .
, , , . , , , ! :