www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2510] New: provide a template instantiation backtrace when compile fails in a template

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: wbaxter 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.


-- 
Dec 12 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2510





------- Comment #1 from kamm-removethis incasoftware.de  2008-12-13 02:18
-------
Created an attachment (id=281)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=281&action=view)
add basic template instantiation traces

We've added this to LDC a while back and I've attached the original diff. It
doesn't cover all cases, but should at least provide a trace for a significant
number of in-template errors.

In order to not spam users, we only print long traces completely when -v is
given. Otherwise only the first and last three steps in the chain are shown.


-- 
Dec 13 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2510


fvbommel wxs.nl changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |someanon yahoo.com




------- Comment #2 from fvbommel wxs.nl  2009-04-26 15:04 -------
*** Bug 2902 has been marked as a duplicate of this bug. ***


-- 
Apr 26 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2510


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com


--- Comment #3 from Stewart Gordon <smjg iname.com> 2009-09-26 11:59:25 PDT ---
You have the same typo in three different places:

    fprintf(stdmsg,"    instantiatied in %s: %s\n", cur->loc.toChars(),
cur->toChars());

instantiatied -> instantiated

And

    while(cur = cur->tinst)

probably ought to be written

    while((cur = cur->tinst) != NULL)

to avoid triggering a "possibly incorrect assignment" warning in some
compilers.

But I like the idea of defaulting to showing the three instantiation levels at
each end of the chain.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 26 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2510


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au


--- Comment #4 from Don <clugdbug yahoo.com.au> 2010-01-13 08:44:08 PST ---
I think this was fixed in the last release, as part of the 'static assert'
patch. Please confirm.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 13 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2510


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #5 from Don <clugdbug yahoo.com.au> 2010-01-20 00:22:12 PST ---
Fixed DMD1.054 and 2.038.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 20 2010