www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Attack of the implicit convertion

reply Julio César Carrascal Urquijo <Julio_member pathlink.com> writes:
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?
Jul 26 2005
next sibling parent Ba Ding Chee <Ba_member pathlink.com> writes:
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. ;)
Jul 26 2005
prev sibling parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"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.
Jul 27 2005