[Bug 77] New: After a compile error occurs, all template instances fail

Don Clugston dac at nospam.com.au
Mon Apr 3 04:03:16 PDT 2006


Walter Bright wrote:
> d-bugmail at puremagic.com wrote:
>> And with a real project, thousands of lines of incorrect error 
>> messages can be
>> generated by a single typo! In fact, I now encounter this bug every 
>> time I get
>> any error message at all. I'd rank it as the most annoying bug in DMD. I
>> consider this severity=major -- I've had to temporarily abandon some 
>> of my
>> metaprogramming work because of it.
> 
> I actually put this in at your suggestion - you suggested that once 
> templates had an error, it was pointless to continue trying to expand 
> them because of a blizzard of cascading errors. I can change it so it 
> just quits on first template error?

Some further thoughts:

If compilation halts immediately that a template error is detected, you 
might not know where the problem actually was. At the very least, you 
also need to know which module was actually being compiled.

Ideally, the compiler would print a "call stack" of which templates were 
instantiated. If the call stack is printed for a recursive function, 
though, the error messages can be a mile long.

So ideally, when an error occurs in a template, the compiler would print 
the error message just as it does right now, then begin to unravel the 
call stack. While doing this, it would not print error messages, but 
merely set up an array of module/line number/instance count for each 
template it encountered. If it had already instantiated that template, 
it would simply increase its instance count.  When it reaches the 
function actually being compiled, the context for the error message 
would finally be printed.

An error message while compiling module 'foo' might look something like:

meta.qualifiednameof(25): undefined identifier b
meta.qualifiednameof(80): recursively instantiated from here
meta.qualifiednameof(50): instantiated from here
meta.qualifiednameof(283): recursively instantiated from here
meta.nameof(15): instantiated from here
foo(15): instantiated from here

Now that it is back in 'foo', compilation could continue.

The important features are:
* there is only one template error message for each template instantiation;
* and we need to know which line of the file instantiated the first 
template.



More information about the Digitalmars-d-bugs mailing list