[Issue 19727] New: std.algorithm.endsWith fails where startsWith succeeds

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 10 11:41:01 UTC 2019


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 at puremagic.com
          Reporter: timosesu at 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.

--


More information about the Digitalmars-d-bugs mailing list