View mode: basic / threaded / horizontal-split · Log in · Help
July 27, 2005
Attack of the implicit convertion
The following code produces an unexpected compile error:

private import std.string;

void main()
{
std.string.toString(cast(dchar)'a');
}

test1.d(135): function std.string.toString called with argument types:
(dchar)
matches both:
std.string.toString(char)
and:
std.string.toString(creal)


¿creal? ¿Why does it match creal?
July 27, 2005
Re: ;) Attack of the implicit convertion
>test1.d(135): function std.string.toString called with argument types:
>(dchar)
>matches both:
>std.string.toString(char)
>and:
>std.string.toString(creal)
>
>
>¿creal? ¿Why does it match creal?
>
>
Well is kinda sounds right, complex numbers are twice as big as reals and have
the letter ‘i's in them. ;)
July 27, 2005
Re: Attack of the implicit convertion
"Julio César Carrascal Urquijo" <Julio_member@pathlink.com> wrote in message 
news:dc719n$1th5$1@digitaldaemon.com...
> test1.d(135): function std.string.toString called with argument types:
> (dchar)
> matches both:
> std.string.toString(char)
> and:
> std.string.toString(creal)
> ¿creal? ¿Why does it match creal?

This error message is quite confusing.  It's because there is no toString() 
overload for wchar or dchar.  You have to cast to char to use toString.

I don't really get why it thinks creal is a match, though.
Top | Discussion index | About this forum | D home