[dmd-internals] Error messages with no line number
Don Clugston
dclugston at googlemail.com
Thu Jun 3 15:27:33 PDT 2010
I followed a suggestion from BCS: I disabled the error function with
no line number (it's in root.h).
I renamed it to errorNoLoc() (with a #ifdef MARS just in case it is
also used by the C++ compiler).
Then watched all the places where it was being called. Most of them
were sensible, but this did catch a four places where its used, that
are probably bugs.
The first one is trivial to fix...
statement.c 4197
void Catch::semantic(Scope *sc)
- error("can only catch class objects, not '%s'", type->toChars());
+ error(loc, "can only catch class objects, not '%s'", type->toChars());
For the other three, it's a bit less obvious which loc to use.
expression.c 518 arrayExpressionToCommonType()
"%s has no value"
template.c 186 match()
error("recursive template expansion for template argument %s", t1->toChars());
init.c, 158 StructInitializer::semantic()
error("%s %s has constructors, cannot use { initializers
}, use %s( initializers ) instead",
ad->kind(), ad->toChars(), ad->toChars());
Based on this quick result, I strongly recommend making a change like
this, it would eliminate a whole class of errors from recurring in
future. Certainly the statement.c bug should be fixed in the next
release, it's so easy.
More information about the dmd-internals
mailing list