Deprecate `!a == b`
Timon Gehr
timon.gehr at gmx.ch
Tue Aug 13 10:14:29 UTC 2024
A bug that crops up now and then in D is that someone negates `a == b`
by prepending a `!`. The result is `!a == b`. This parses as `(!a) == b`
and will often silently do the wrong thing because negation implies cast
to `bool`, and `bool` can be compared with integral types and `enum`
members.
I think it would be better for this to give a diagnostic and require
explicit parentheses, similar to bitwise operators (where the operator
precedence is unintuitive in the other direction).
More information about the dip.ideas
mailing list