You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following source code doesn't compile because in the lambda 'a.bar' is written instead of 'a.foo'.
import std.algorithm: canFind;
struct A { string foo; }
void main()
{
A[] arr;
arr.canFind!(a => a.bar);
}
It isn't clear from the error message, that the property'bar' is causing the error:
source\app.d(9):
Error: template std.algorithm.canFind cannot deduce function
from argument types !((a) => a.bar)(A[]), candidates are:
C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(11266): std.algorithm.canFind(alias pred = "a == b")
I would expect an error message: no property 'bar' for type 'A'
The text was updated successfully, but these errors were encountered:
Like Issue 13683, this is caused by canFind's template constraint rather than dmd. It could be changed to use a static assert, so that the error mentions that the lambda can't take an A.
andre reported this on 2015-02-23T15:55:24Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=14217
CC List
Description
The following source code doesn't compile because in the lambda 'a.bar' is written instead of 'a.foo'. import std.algorithm: canFind; struct A { string foo; } void main() { A[] arr; arr.canFind!(a => a.bar); } It isn't clear from the error message, that the property'bar' is causing the error: source\app.d(9): Error: template std.algorithm.canFind cannot deduce function from argument types !((a) => a.bar)(A[]), candidates are: C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(11266): std.algorithm.canFind(alias pred = "a == b") I would expect an error message: no property 'bar' for type 'A'The text was updated successfully, but these errors were encountered: