[Issue 2510] New: provide a template instantiation backtrace when compile fails in a template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 12 18:59:52 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2510

           Summary: provide a template instantiation backtrace when compile
                    fails in a template
           Product: D
           Version: 1.038
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: wbaxter at gmail.com


It's very annoying to get a compiler message that consists of nothing but:

" error: ATemplateFunction: int does not have a .length property"

Where ATemplateFunction is something like

void ATemplateFunction(ArrayT)(ArrayT  x) {
    auto n = x.length;
    ....
}

Great so I know that *somewhere* in all my source code I called
ATemplateFunction with the wrong kind of argument.  The compiler knows where it
was that I made the call, but it just doesn't care to enlighten me.  Very
frustrating.

I seem to recall a discussion at one point where Walter said that template
instantiation backtraces make template errors look too complicated.  And I can
see the reasoning in that, but omitting them entirely is like chopping off the
developer's legs just because his toes are cold.

So I have a couple of suggestions:

1) Only print the backtrace when compiling with -v.  That way most of the time
you don't have to see it.  Only when you're really stuck will you pull out the
-v guns to figure out what the issue is.

2) Just print out an abbreviated backtrace that consists of only file names and
line numbers.

3) Do some combination of 1 and 2.


-- 



More information about the Digitalmars-d-bugs mailing list