std.stdio breaks casting operation

tcak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 23 11:43:52 PDT 2014


The main function has following:

- main.d -

	import test;
	auto t = new shared test.Test();
	auto sock = new std.socket.TcpSocket( 
std.socket.AddressFamily.INET6 );
	t.setIt( sock );


- test.d -

module test;

import std.socket;

public class Test{
	private std.socket.Socket s;

	public void setIt(S)( S sock) shared
		if(
			is(S: std.socket.Socket) ||
			is(S: shared(std.socket.Socket))
		)
	{
		s = cast( typeof( s ) )sock;
	}
}


Above code works properly (I mean there is no error at all).

=====

Then I change the "Test.setIt" method as follows:

		import std.stdio;
		s = cast( typeof( s ) )sock;


Error on "s = cast..." line:
cannot cast module socket of type void to shared(Socket)

===

What is casting a module? How is this happening? Is this a bird, 
superman, or a bug?


More information about the Digitalmars-d-learn mailing list