toString not working... (a bug in D?)

Leopold Walkling leopold_walkling at web.de
Tue Jan 16 06:05:05 PST 2007


Hello Marcin,

> Orgoton wrote:
> 
>> Ok, now I did
>> 
>> import std.string;
>> ushort number=1092;
>> char[] text="Some text " ~ toString(number);
>> and the compiler claimed that the number of arguments of
>> Object.object.toString() did not match... So, I did
>> 
>> char[] text="Some text " ~ std.string.toString(number);
>> 
>> and it worked fine. Is this a compiler bug? I did not import object
>> (as it is implicitly done). Or have I some weird compiler
>> configuration?
>> 
> Probably you did:
> char[] text="Some text " ~ toString(number);
> in class method, so compiler thought you want to refer to Object's
> toString() method.
> 
> You should escape current scope of class with '.' (dot).
> class Test {
> void method(int number) {
> char[] text="Some text " ~ .toString(number);
> }
> }
> Above code should work.
> 


This problem only occurs if you import specific modules (std.thread). So 
if you comment out that line, you can use toString without the dot, this 
isn't the wanted behavior, right?





More information about the Digitalmars-d mailing list