www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9160] New: 2.061alpha multiSort no longer working with L-value only comparators

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9160

           Summary: 2.061alpha multiSort no longer working with L-value
                    only comparators
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: dmitry.olsh gmail.com



06:01:52 PST ---
Changing DMD to no longer accept struct literals as L-value as a side effect
broke template constraint in std.algorithm.multiSort:

7556: is(typeof(binaryFun!(less[0])(E.init, E.init)) == bool)

The E.init is not an L-value and thus the code below no longer works:

import std.algorithm;

struct A{
    int x;
    int y;
    //... potentially quite big struct
}

bool byX(const ref A lhs, const ref A rhs)
{
    return lhs.x < rhs.x;
}

bool byY(const ref A lhs, const ref A rhs)
{
    return lhs.y < rhs.y;
}

void main()
{
    auto points = [ A(4, 1), A(2, 4)];
    multiSort!(byX, byY)(points);
    assert(points[0] == A(2, 4));
    assert(points[1] == A(4, 1));
}

A chunk of text for this error:

multi_bug.d(22): Error: template std.algorithm.multiSort!(byX, byY).multiSort
do
es not match any function template declaration. Candidates are:
C:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(7712):       
std.algorithm
.multiSort!(byX, byY).multiSort(Range)(Range r) if
(validPredicates!(ElementType
!(Range), less))
multi_bug.d(22): Error: template std.algorithm.multiSort!(byX,
byY).multiSort(Ra
nge)(Range r) if (validPredicates!(ElementType!(Range), less)) cannot deduce
tem
plate function from argument types !()(A[])

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 15 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9160




06:15:12 PST ---
https://github.com/D-Programming-Language/phobos/pull/1011

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 15 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9160




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/bde7cbad4dc1effa5ca2c23459b63717246244aa
fix issue 9160 multiSort constraint bug

https://github.com/D-Programming-Language/phobos/commit/194ca0780390b2949cba95cea118d4833b5f39c6


fix issue 9160 multiSort constraint regression

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 16 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9160


Kenji Hara <k.hara.pg gmail.com> changed:

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


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