On 6/16/13 9:04 AM, Adam D. Ruppe wrote:
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.

At a minimum the full signature should be in the error message.

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


Andrei

Reply via email to