Bug 23663 – Better error message for template with missing function

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2023-02-01T12:48:34Z
Last change time
2023-02-01T21:57:45Z
Assigned to
No Owner
Creator
Grim Maple
See also
https://issues.dlang.org/show_bug.cgi?id=13683

Comments

Comment #0 by grimmaple95 — 2023-02-01T12:48:34Z
Consider code below: ``` import std; void main() { auto a = [1, 2, 3]; a.each!(x => callback(x)); void callback(int a) { writeln(a); } } ``` The error message is completely bogus. It should just say that it can't find "callback". Current error message: ``` onlineapp.d(7): Error: none of the overloads of template `onlineapp.main.each!((x) => callback(x)).each` are callable using argument types `!()(int[])` /dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/iteration.d(908): Candidates are: `each(Range)(Range r)` with `Range = int[]` must satisfy one of the following constraints: ` isRangeIterable!Range __traits(compiles, typeof(r.front).length)` /dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/iteration.d(969): `each(Iterable)(auto ref Iterable r)` with `Iterable = int[]` must satisfy one of the following constraints: ` isForeachIterable!Iterable __traits(compiles, Parameters!(Parameters!(r.opApply)))` ```
Comment #1 by nick — 2023-02-01T21:41:16Z
*** This issue has been marked as a duplicate of issue 11907 ***