Deprecate `!a == b`
Nicholas Wilson
iamthewilsonator at hotmail.com
Wed Aug 14 01:00:13 UTC 2024
On Tuesday, 13 August 2024 at 20:55:09 UTC, Nick Treleaven wrote:
> On Tuesday, 13 August 2024 at 10:14:29 UTC, Timon Gehr wrote:
>> 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 was a bit surprised that someone would write that (other than
> someone new to C-like syntax), but then I saw:
> https://github.com/dlang/dmd/pull/16778#discussion_r1715017456
In my defence, I was half asleep and recovering from a cold, but
CI would have caught this.
Having said that, I agree, it should be made an error. Well
deprecation then error, it probably doesn't need to be a DIP
More information about the dip.ideas
mailing list