Bug 2616 – Undocumented behaviour: part-explicit, part-implicit instantiations of function templates are accepted

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2009-01-25T16:10:00Z
Last change time
2014-03-01T00:36:31Z
Keywords
accepts-invalid, spec
Assigned to
nobody
Creator
smjg
Blocks
2599, 677

Comments

Comment #0 by smjg — 2009-01-25T16:10:37Z
`Function templates can be explicitly instantiated with a !(TemplateArgumentList): writefln("The square of %s is %s", 3, Square!(int)(3)); or implicitly, where the TemplateArgumentList is deduced from the types of the function arguments: writefln("The square of %s is %s", 3, Square(3)); // T is deduced to be int` It's just come to my attention that the compiler allows an in-between case that isn't covered by the current documentation, either for D1 or for D2. ---------- import std.stdio; void fun(T1, T2)(T2 x) { pragma(msg, T1.stringof); writefln(x); } void main() { fun!(int)("hello!"); } ---------- C:\Users\Stewart\Documents\Programming\D\Tests>dmd template_partial.d int C:\Users\Stewart\Documents\Programming\D\Tests>template_partial hello! ---------- What is T2? The template instantiation is explicit in form, but doesn't match the parameter list with which the template is declared. Neither is T2 deduced from the given template arguments. Neither is it IFTI as currently documented, since a template parameter list has been given. Rather, the template instantiation is of an undocumented mix of the two styles. Issue 2599 comment 6 implies that this feature is intended, but you forgot to document it.
Comment #1 by wbaxter — 2009-01-25T18:12:46Z
See this bug: http://d.puremagic.com/issues/show_bug.cgi?id=493 It was mentioned in the changelog of 1.038. It could certainly be documented better.
Comment #2 by bugzilla — 2010-11-09T16:39:15Z