Summary: Make == null a warning for arrays
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD

--- Comment #0 from Jonathan M Davis <> 2011-07-18 12:51:46 
PDT ---
The correct way to test whether something in null in D is to use is. Using ==
null with strings is doing the same as checking whether their length == 0. This
is _not_ what most people are going to expect. So, if you actually understand
the rules, then the correct way to check for null is is null, and the correct
way to check for empty is to either use length == 0 or std.array.empty. As
such, there is no point in using == and if it's in the code, there's a good
chance that it's a bug.

It appears that there is _already_ such a warning when dealing with classes. I
think that it would be far less error-prone to make the same warning apply to
arrays. I don't think that there is really a reasonable case for use == null in
D at all, so in all cases, it should generate a warning. is null is what
actually checks for null, and there are better, clearer ways to check for empty
with arrays.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to