error messages that could be better

Adam D. Ruppe destructionator at gmail.com
Sun Jun 16 06:04:21 PDT 2013


Yesterday, I was working on a socket code and wrote this:

this(string host, uint port) {
     socket.connect(new InternetAddress(host, port));
}

and got this:

server.d(109): Error: constructor std.socket.InternetAddress.this 
() is not callable using argument types (string, uint)
server.d(109): Error: no constructor for InternetAddress


It took me several minutes to realize my real mistake: I wrote 
"uint" when I meant "ushort". The error message was less than 
helpful because I was quite certain this was how it worked, but 
it was complaining about this() rather than this(string, ushort), 
so maybe I forgot how to construct this thing.



The error messages can catch simple spelling errors with a 
distance of one edit from the correct name, but here it couldn't 
catch a type mismatch with a similar distance of one from the 
real thing.

If it did that, I would have spent 5 seconds on this rather than 
5 minutes.


More information about the Digitalmars-d mailing list