Bug 15658 – isFile isn't a template

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-02-08T19:05:31Z
Last change time
2020-03-21T03:56:42Z
Assigned to
Basile-z
Creator
Cédric Picard

Comments

Comment #0 by cpicard — 2016-02-08T19:05:31Z
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
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/45d15b9f0558689cd3e7dd1e96784aca62cc438b fix issue 15658 - UFCS used in isFile conflict with DirEntry member https://github.com/D-Programming-Language/phobos/commit/9c8f1a35da6d82d133ad08ef56326061d337717e Merge pull request #4104 from BBasile/issue-15658 fix issue 15658 - UFCS used in isFile caused a conflict with a DirEntry member