[dmd-internals] Error messages with no line number

Don Clugston dclugston at googlemail.com
Fri Jun 4 00:55:12 PDT 2010


On 4 June 2010 00:53, Trass3r <mrmocool at gmx.de> wrote:
> Yeah the error handling is a mess.
> There are several different versions of error() in different places (mars.c,
> root.c, expression.c, ...). Some add loc by themselves, some don't (like the
> global one you mentioned).

That function I mentioned is the only one which doesn't add loc. The
problem is, that if you have code in a member function which calls
error(), then turn it into a static member function, it will happily
compile, but the errors will have no longer have a line number since
the no-loc error() function has been called.

> In todt.c:141 an error function is called but neither Visual Studio's
> IntelliSense nor VisualAssist's usually very smart one can detect which one
> is called.
>
>
> Additionally in the following issue Expression::error() is called in
> todt.c:683 which normally does add loc to the message, but for some reason
> loc is null:
> http://d.puremagic.com/issues/show_bug.cgi?id=4241

That's a different issue, it's caused when a semantic transformation
is done, and the compiler creates new expressions, explicitly passing
NULL as the loc parameter. The error message shouldn't be created at
all, because it refers to compiler-generated code, not source code.

Missing line numbers of the first type are easily preventable by just
changing the name of the error() function, as I have done. As I
previously mentioned, there are currently 4 such bugs in DMD at
present. It's low-hanging fruit.


More information about the dmd-internals mailing list