https://issues.dlang.org/show_bug.cgi?id=16467
Jonathan M Davis <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] | |m --- Comment #1 from Jonathan M Davis <[email protected]> --- I suspect that this will be declared to be "not a bug." While, I can understand your reasoning, the problem is that when you pass a string to your identity function, IFTI instantiates it with string. It's only called _after_ the function has been compiled, and the default argument does not work with the type in question. Remember that templatizing a function directly is just shorthand for declaring an eponymous template that it's a function. So, this would be equivalent to what you declared: template identity(T) { T identity(T t = 0) { return t; } } And if the template is instantiated with string, then the default argument is not valid. Also consider the case where you do auto result = identity!string(); It's exactly the same template instantiation as identity("hello"), but it would need the default argument, which is the wrong type. --
