http://d.puremagic.com/issues/show_bug.cgi?id=4901

           Summary: std.algorithm.sort does not compile for interfaces
                    that cannot be printed.
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nob...@puremagic.com
        ReportedBy: schvei...@yahoo.com


--- Comment #0 from Steven Schveighoffer <schvei...@yahoo.com> 2010-09-20 
05:44:56 PDT ---
An assert meant to check the sort algorithm inadvertently makes it uncompilable
for interfaces.

reduced test case:

import std.algorithm;

interface I
{
   @property int x();
}

bool iless(I i1, I i2)
{
    return i1.x < i2.x;
}

void main()
{
    I[] x;
    std.algorithm.sort!iless(x);
}

outputs:
/home/steves/dmd-2.049/linux/bin/../../src/phobos/std/conv.d(95): Error:
template std.conv.toImpl(T,S) if (!implicitlyConverts!(S,T) && isSomeString!(T)
&& isInputRange!(S) && isSomeChar!(ElementType!(S))) does not match any
function template declaration
/home/steves/dmd-2.049/linux/bin/../../src/phobos/std/conv.d(95): Error:
template std.conv.toImpl(T,S) if (!implicitlyConverts!(S,T) && isSomeString!(T)
&& isInputRange!(S) && isSomeChar!(ElementType!(S))) cannot deduce template
function from argument types !(string)(I)
/home/steves/dmd-2.049/linux/bin/../../src/phobos/std/conv.d(95): Error:
template instance errors instantiating template
/home/steves/dmd-2.049/linux/bin/../../src/phobos/std/conv.d(202): Error:
template instance std.conv.to!(string).to!(I) error instantiating
/home/steves/dmd-2.049/linux/bin/../../src/phobos/std/conv.d(95):       
instantiated from here: toImpl!(string,I[])
/home/steves/dmd-2.049/linux/bin/../../src/phobos/std/conv.d(3556):       
instantiated from here: to!(I[])
/home/steves/dmd-2.049/linux/bin/../../src/phobos/std/conv.d(3572):       
instantiated from here: textImpl!(string,string,string,I[])
/home/steves/dmd-2.049/linux/bin/../../src/phobos/std/algorithm.d(5187):       
instantiated from here: text!(string,string,I[])
testsort.d(16):        instantiated from here:
sort!(iless,cast(SwapStrategy)0,I[])


Line 5187 of std.algorithm is this:

        assert(isSorted!lessFun(r), text(Range.stringof, ": ", r));

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to