Can't "is null" an interface?!?! Incompatible types???

Nick Sabalausky (Abscissa) SeeWebsiteToContactMe at semitwist.com
Thu Mar 8 04:48:08 UTC 2018


---------------------
import vibe.core.net;
TCPConnection mySocket;

void main() {
     auto b = mySocket is null;
}
---------------------

That's giving me:

---------------------
Error: incompatible types for (mySocket) is (null): TCPConnection and 
typeof(null)
---------------------

WTF?!?!

The type in question (vibe.core.net.TCPConnection) is an interface:
http://vibed.org/api/vibe.core.net/TCPConnection
https://github.com/vibe-d/vibe.d/blob/master/core/vibe/core/net.d#L344

The following works just fine:
---------------------
interface IFoo {}

void main() {
     IFoo i;
     auto b = i is null;
}
---------------------



More information about the Digitalmars-d-learn mailing list