Bug 10438 – Improve template deduction error message

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-21T08:18:11Z
Last change time
2020-03-21T03:56:35Z
Assigned to
No Owner
Creator
Jerry Quinn

Comments

Comment #0 by jlquinn — 2013-06-21T08:18:11Z
import std.array; void main() { auto app = appender!char(); } /home/jlquinn/dmd2/linux/bin64/dmd junk.d junk.d(3): Error: template std.array.appender does not match any function template declaration. Candidates are: /home/jlquinn/dmd2/linux/bin64/../../src/phobos/std/array.d(2502): std.array.appender(A : E[], E)(A array = null) /home/jlquinn/dmd2/linux/bin64/../../src/phobos/std/array.d(2611): std.array.appender(A : E[]*, E)(A array) /home/jlquinn/dmd2/linux/bin64/../../src/phobos/std/array.d(2502): Error: template std.array.appender cannot deduce template function from argument types !(char)() junk.d(3): Error: template instance appender!(char) errors instantiating template It took a little puzzling for me to figure out what was wrong (I know an experienced D dev wouldn't have trouble). In this case, I'd love to see a message describing why a template alternative doesn't match. For example, something like: /home/jlquinn/dmd2/linux/bin64/../../src/phobos/std/array.d(2502): std.array.appender(A : E[], E)(A array = null) no match because char is not an array slice This is clearly an enhancement, but info like this would go a long way towards speeding up the ability to figure out why template heavy code isn't compiling.
Comment #1 by b2.temp — 2020-02-20T09:48:53Z
this was done recently: /tmp/temp_7FE8BCD48130.d(7,28): Error: template `std.array.appender` cannot deduce function from argument types `!(char)()`, candidates are: /usr/include/dmd/phobos/std/array.d(3838,12): `appender(A)()` with `A = char` must satisfy the following constraint: ` isDynamicArray!A` /usr/include/dmd/phobos/std/array.d(3844,16): `appender(A : E[], E)(auto ref A array)` /usr/include/dmd/phobos/std/array.d(4261,19): `appender(P : E[]*, E)(P arrayPtr)`