Thread overview
Attack of the implicit convertion
Re: ;) Attack of the implicit convertion
Jul 27, 2005
Ba Ding Chee
July 27, 2005
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
>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
"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.