Unhelpful error messages
Peter Alexander
peter.alexander.au at gmail.com
Sun Jul 7 05:06:46 PDT 2013
On Sunday, 7 July 2013 at 06:58:29 UTC, Maxim Fomin wrote:
> http://d.puremagic.com/issues/
Ironically, this isn't helpful. H. S. Teoh is opening up a
discussion, not reporting a bug.
The problem here is more general than this specific case. Any
template constraint on any function could fail to pass, and the
best error you'll get is that it couldn't match any function.
Even if the error messages were improved to tell you what part of
the constraint failed, you still have no idea *why* it failed
(e.g. *why* is my range not a forward range?)
Overloads just make matters exponentially worse. Not only can the
compiler fail to provide a good error for a single function, but
needs to provide a good error for every possible candidate
function. If a constraint checks if another overloaded function
is callable then you end up with a combinatorial explosion of
reasons why your function didn't compile.
It's a tough situation and I think the only way this could even
reasonably be resolved is through some sophisticated IDE
integration. There is no way to display this kind of error report
in a blob of command line text.
More information about the Digitalmars-d
mailing list