std.stdio breaks casting operation

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 23 12:36:09 PDT 2014


On Thursday, 23 October 2014 at 19:20:54 UTC, anonymous wrote:
> On Thursday, 23 October 2014 at 18:43:54 UTC, tcak wrote:
>> 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)
>
> Apparently std.stdio defines an alias `sock` to some module. 
> When
> you import std.stdio, its `sock` takes precedence over the
> parameter `sock`.

It's been discussed recently, but I can't find it now. It's a 
natural result of the scope hierarchy: parameters are in a higher 
scope than the function body, into which the identifiers from 
std.stdio get imported.

It's been recognized that this is often unexpected, and different 
lookup rules have been debated, but I think there was no clear 
conclusion.

But in this particular case, it has already been fixed, and will 
work in the next release:
https://github.com/D-Programming-Language/phobos/pull/2395


More information about the Digitalmars-d-learn mailing list