I get a strange error when not using UFCS with isFile on a DirEntry with DMD v0.270.0
To reproduce:
$ cat test.d
void main() {
import std.file, std.algorithm;
dirEntries("/tmp/", SpanMode.breadth).filter!(f => isFile(f));
}
$ dmd test.d
/usr/include/dlang/dmd/std/file.d(1743): Error: name.isFile isn't a template
test.d(7): Error: template instance std.file.isFile!(DirEntry) error instantiating
/usr/include/dlang/dmd/std/algorithm/iteration.d(985): instantiated from here: __lambda2!(DirEntry)
/usr/include/dlang/dmd/std/algorithm/iteration.d(944): instantiated from here: FilterResult!(__lambda2, DirIterator)
test.d(7): instantiated from here: filter!(DirIterator)
It is easy to circumvent though:
$ cat test2.d
void main() {
import std.file, std.algorithm;
dirEntries("/tmp/", SpanMode.breadth).filter!(f => f.isFile);
}
$ dmd test.d
<no output, ok>
Comment #1 by b2.temp — 2016-03-22T01:10:36Z
It's not a UFCS issue:
"dirEntries()" doesn't return a range of string. It returns a range of "struct DirEntry{}" . This struct itself contains a member function called "isFile()", which is not a template.
Latter in std.file.isFile() this member is called because in
@property bool isFile(R)(auto ref R name)
if (isConvertibleToString!R)
{
return name.isFile!(StringTypeOf!R);
}
it's DirEntry.isFile that get called !!
Comment #2 by github-bugzilla — 2016-03-24T20:54:30Z