digitalmars.D.bugs - [Issue 1515] New: compiler accepts invalid template declaration
- d-bugmail puremagic.com (23/23) Sep 18 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1515
- d-bugmail puremagic.com (18/18) Oct 29 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1515
http://d.puremagic.com/issues/show_bug.cgi?id=1515 Summary: compiler accepts invalid template declaration Product: D Version: 1.014 Platform: PC OS/Version: Windows Status: NEW Severity: trivial Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: davidl 126.com template A(T) { alias T type; } template B(T:A!(T).type) // I think compiler should ban the use of reuse the same type identifier in the specialization part. { } //mixin B!(int); // even though you can't instantiate the template, the compiler can actually emit nicer message; --
Sep 18 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1515 smjg iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg iname.com AIUI this is by design, though admittedly it's a rather strange design. http://www.digitalmars.com/d/1.0/template.html template TBar(T : T*) { } alias TBar!(char*) Foo3; // (2) T is deduced to be char Basically, what it means is that if a template parameter name is re-used as part of the specialization, it has the meaning of 'anything', and within the template, the identifier denotes what it represented within the specialization. But where T is used as a template parameter in the specialization, I'm not sure it can work in the general case. After all, there's a potential infinitude of templates to instantiate to try to find a match. So I'm still not sure that the compiler should accept the template declaration. --
Oct 29 2007