Thread overview
[Issue 6346] Make == null a warning for arrays
Aug 07, 2014
Orvid King
Aug 07, 2014
Jonathan M Davis
Dec 17, 2022
Iain Buclaw
August 07, 2014
https://issues.dlang.org/show_bug.cgi?id=6346

Orvid King <blah38621@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |blah38621@gmail.com

--- Comment #10 from Orvid King <blah38621@gmail.com> ---
Not sure, but isn't this currently an error?

--
August 07, 2014
https://issues.dlang.org/show_bug.cgi?id=6346

--- Comment #11 from Jonathan M Davis <jmdavisProg@gmx.com> ---
(In reply to Orvid King from comment #10)
> Not sure, but isn't this currently an error?

No. It's perfectly legal to compare against null. null is basically the same as []. As far as the compiler is concerned, in the context of arrays, null is just an empty array. IMHO, it's very frustrating that that's the case, but we're stuck with it at this point.

And I should probably just close this issue. Due to how the compiler tries to treat null as the same an empty array in almost all contexts, even trying to distinguish between a null array and an empty one is tricky and error-prone - to the point that if you really want a null array, it would arguably be better to wrap it in a Nullable, which is kind of silly IMHO, since arrays _are_ nullable, but since the compiler only treats null as special _some_ of the time, you have to be very careful if you want to treat it as special.

--
June 09, 2015
https://issues.dlang.org/show_bug.cgi?id=6346

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unspecified                 |D2

--
October 15, 2016
https://issues.dlang.org/show_bug.cgi?id=6346

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |bootcamp
                 CC|                            |andrei@erdani.com

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=6346

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P4

--