www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Can't "is null" an interface?!?! Incompatible types???

reply "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
---------------------
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;
}
---------------------
Mar 07 2018
parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Thursday, 8 March 2018 at 04:48:08 UTC, Nick Sabalausky 
(Abscissa) wrote:
 ---------------------
 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;
 }
 ---------------------
That does seem odd. --- /+dub.sdl: dependency "vibe-d" version="~>0.8.3-alpha.1" +/ import vibe.core.net; import std.stdio; TCPConnection mySocket; void main() { auto b = mySocket is null; writeln(b); } --- works fine on run.dlang.io
Mar 07 2018
parent reply "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
On 03/08/2018 01:13 AM, Nicholas Wilson wrote:
 
 That does seem odd.
 ---
 /+dub.sdl:
 dependency "vibe-d" version="~>0.8.3-alpha.1"
 +/
 import vibe.core.net;
 import std.stdio;
 TCPConnection mySocket;
 
 void main() {
      auto b = mySocket is null;
      writeln(b);
 }
 ---
 works fine on run.dlang.io
Interesting. I was using vibe.d 'v0.8.3-rc.1' (which doesn't appear to work on run.dlang.io). But it does seem to work for me if I use 'v0.8.3-alpha.1'. I wonder what could have changed to result in this?
Mar 08 2018
next sibling parent "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
On 03/08/2018 03:04 AM, Nick Sabalausky (Abscissa) wrote:
 
 Interesting. I was using vibe.d 'v0.8.3-rc.1' (which doesn't appear to 
 work on run.dlang.io). But it does seem to work for me if I use 
 'v0.8.3-alpha.1'.
 
 I wonder what could have changed to result in this?
https://github.com/vibe-d/vibe.d/issues/2108
Mar 08 2018
prev sibling parent Jacob Carlborg <doob me.com> writes:
On Thursday, 8 March 2018 at 08:04:54 UTC, Nick Sabalausky 
(Abscissa) wrote:

 Interesting. I was using vibe.d 'v0.8.3-rc.1' (which doesn't 
 appear to work on run.dlang.io). But it does seem to work for 
 me if I use 'v0.8.3-alpha.1'.

 I wonder what could have changed to result in this?
It's a struct in "v0.8.3-rc.1" [1]. In "v0.8.3-rc.1" the new vibe-core package is the default configuration. [1] https://github.com/vibe-d/vibe-core/blob/master/source/vibe/core/net.d#L467 -- /Jacob Carlborg
Mar 08 2018