www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19727] New: std.algorithm.endsWith fails where startsWith

https://issues.dlang.org/show_bug.cgi?id=19727

          Issue ID: 19727
           Summary: std.algorithm.endsWith fails where startsWith succeeds
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: timosesu gmail.com

startsWith succeeds but endsWith fails.


    import std.stdio;
    import std.algorithm;
    import std.file;
    import std.path;

    void main()
    {
        string[] ex = ["abc", "def", "ghi"];
        string t = "/folder/test.ghi";

        // works
        writeln(ex.any!(e => t.asRelativePath("/folder").startsWith(e)));
        // fails
        writeln(ex.any!(e => t.asRelativePath("/folder").endsWith(e)));
    }


Fails with:
source/app.d(12,15): Error: template app.main.any!((e) =>
t.asRelativePath("/folder").endsWith(e)).any cannot deduce function from
argument types !()(string[]), candidates are:
/Library/D/dmd/src/phobos/std/algorithm/searching.d(169,10):       
app.main.any!((e) => t.asRelativePath("/folder").endsWith(e)).any(Range)(Range
range) if (isInputRange!Range && is(typeof(unaryFun!pred(range.front))))
dmd failed with exit code 1.

--
Mar 10 2019