www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4901] New: std.algorithm.sort does not compile for interfaces that cannot be printed.

reply d-bugmail puremagic.com writes:
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: nobody puremagic.com
        ReportedBy: schveiguy yahoo.com



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: -------
Sep 20 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4901


Steven Schveighoffer <schveiguy yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



10:32:41 PST ---
Fixed in svn : http://www.dsource.org/projects/phobos/changeset/2226

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