On Sunday, January 28, 2018 20:02:48 welkam via Digitalmars-d-learn wrote: > Error says that it cant deduce function from argument types but > in reality it fails to meet function template constraints. In > this case !is(CommonType!(staticMap!(ElementType, > staticMap!(Unqual, Ranges))) == void) > > In human terms it means that arguments are not the same type. Is > this require bug report or it works as expected? > > Code: > void main() { > import std.range : chain; > string s = "string"; > auto arrayOfStrings = ["string"]; > arrayOfStrings.chain(s); > } > > error: > Main.d(9): Error: template std.range.chain cannot deduce function > from argument types !()(string[], string), candidates are: > C:\D\dmd2\windows\bin\..\..\src\phobos\std\range\package.d(894): > std.range.chain(Ranges...)(Ranges rs) if (Ranges.length > 0 > && allSatisfy!(isInputRange, staticMap!(Unqual, Ranges)) && > !is(CommonType!(staticMap!(ElementType, staticMap!(Unqual, > Ranges))) == void))
There is nothing incorrect about the error message. The compiler looked at all of the functions in the overload set, and it found none that matched. The reason that it found none that matched was because it couldn't find any function template where those arguments passed the template constraint, and it tells you so. So, there is no bug here in the sense that the compiler is telling you the wrong thing. You can certainly open a bug report arguing that the error messages isn't human-friendly enough and suggest alternatives, and something along those lines may be implemented, but the message isn't actually wrong. So, feel free to open a bug report. However, you're not going to get an error message that says anything like "the arguments aren't the same type." The compiler doesn't understand what the template constraint means in "human terms." It just knows whether it's true or false, and in this case, if you provide arguments that don't have a common type that they implicitly convert to, then the template constraint will fail. But ultimately, you're going to have to read the template constraint and figure out why the arguments are failing. - Jonathan M Davis