I'm sitting here trying to figure out why I can't combine join pathSplitter components with pathSeparator.

import std.range, std.path;

void bug()
{
    auto comps = pathSplitter("foo/bar");
    auto path = join(comps, pathSeparator);
}

This is the error message:

path.d(6): Error: template std.array.join does not match any function template declaration. Candidates are: DPL/dmd/src/../../phobos/std/array.d(1559): std.array.join(RoR, R)(RoR ror, R sep) if (isInputRange!RoR && isInputRange!(ElementType!RoR) && isInputRange!R && is(Unqual!(ElementType!(ElementType!RoR)) == Unqual!(ElementType!R))) DPL/dmd/src/../../phobos/std/array.d(1606): std.array.join(RoR)(RoR ror) if (isInputRange!RoR && isInputRange!(ElementType!RoR)) path.d(6): Error: template std.array.join(RoR, R)(RoR ror, R sep) if (isInputRange!RoR && isInputRange!(ElementType!RoR) && isInputRange!R && is(Unqual!(ElementType!(ElementType!RoR)) == Unqual!(ElementType!R))) cannot deduce template function from argument types !()(PathSplitter, string)

This is what I currently have to do to figure out what is going on.

    // declare types of arguments
    alias RoR = typeof(comps);
    alias R = typeof(pathSeparator);
    // static assert each constraint
    static assert(isInputRange!RoR);
    // Bingo!
    static assert(isInputRange!(ElementType!RoR));
// path.d(9): Error: static assert (isInputRange!(const(char[]))) is false
    static assert(isInputRange!R);
static assert(is(Unqual!(ElementType!(ElementType!RoR)) == Unqual!(ElementType!R)));

A useful error message should be something along this line.

path.d(6): Error: Can't call template function 'join' because the element type of 'comps' is not an input range.

path.d(6): Error: Can't call template function 'join' because the following constraint failed. isInputRange!(ElementType!RoR), RoR == const(char[]) deduced from argument 'comps'.

Reply via email to