[Issue 23663] New: Better error message for template with missing function
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Wed Feb  1 12:48:34 UTC 2023
    
    
  
https://issues.dlang.org/show_bug.cgi?id=23663
          Issue ID: 23663
           Summary: Better error message for template with missing
                    function
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: grimmaple95 at gmail.com
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)))`
```
--
    
    
More information about the Digitalmars-d-bugs
mailing list