D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1193 - regression: "matches more than one template declaration" doesn't list the location of the conflicting templates
Summary: regression: "matches more than one template declaration" doesn't list the loc...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P3 regression
Assignee: No Owner
URL:
Keywords: diagnostic, patch
Depends on:
Blocks:
 
Reported: 2007-04-27 12:57 UTC by Thomas Kühne
Modified: 2014-02-16 15:23 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Thomas Kühne 2007-04-27 12:57:45 UTC
# template fn( T ) {
#    void fn() {
#    }
# }
#
# template fn( T ) {
#    void fn( T val ) {
#    }
# }
#
# void main() {
#    mixin fn!(int);
# }

DMD-1.010:
nocompile/t/template_25_A.d(18): template 
dstress.nocompile.t.template_25_A.fn(T) conflicts with 
dstress.nocompile.t.template_25_A.fn(T) at nocompile/t/template_25_A.d(13)

DMD-1.013:
nocompile/t/template_25_A.d(24): mixin fn!(int) matches more than one template 
declaration, fn(T) and fn(T)

test cases:
http://dstress.kuehne.cn/nocompile/t/template_25_A.d
http://dstress.kuehne.cn/nocompile/t/template_class_17.d
http://dstress.kuehne.cn/nocompile/t/template_struct_07.d
Comment 1 Brad Roberts 2010-05-19 00:00:25 UTC
quick easy fix for this one (against dmd 2.x, but likely applies easily enough to 1.x):

diff --git a/src/template.c b/src/template.c
--- a/src/template.c
+++ b/src/template.c
@@ -4313,8 +4313,10 @@ TemplateDeclaration *TemplateInstance::findBestMatch(Scope *sc)
     }
     if (td_ambig)
     {
-        error("%s matches more than one template declaration, %s and %s",
-                toChars(), td_best->toChars(), td_ambig->toChars());
+        error("%s matches more than one template declaration, %s(%d):%s and %s(%d):%s",
+                toChars(),
+                td_best->loc.filename, td_best->loc.linnum, td_best->toChars(),
+                td_ambig->loc.filename, td_ambig->loc.linnum, td_ambig->toChars());
     }
 
     /* The best match is td_best

Results in:
bug1193.d(12): Error: mixin fn!(int) matches more than one template declaration, bug1193.d(1):fn(T) and bug1193.d(6):fn(T)
Comment 2 Walter Bright 2010-06-02 00:49:58 UTC
http://www.dsource.org/projects/dmd/changeset/515