D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 15658 - isFile isn't a template
Summary: isFile isn't a template
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: basile-z
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-08 19:05 UTC by Cédric Picard
Modified: 2020-03-21 03:56 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Cédric Picard 2016-02-08 19:05:31 UTC
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 basile-z 2016-03-22 01:10:36 UTC
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 github-bugzilla 2016-03-24 20:54:30 UTC
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