www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15091] New: Error passing lambda to std.algorithm.sorting.sort


          Issue ID: 15091
           Summary: Error passing lambda to std.algorithm.sorting.sort
           Product: D
           Version: D2
          Hardware: All
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: nicolas.jinchereau gmail.com

Compiles fine in release mode, but gives error in debug mode:

dmd main.d -debug

module main;
import std.algorithm;
import std.container;

struct S {
    int value;

void main(string[] args)
    Array!S stuff = [S(3), S(1), S(2)];
    stuff[].sort!((ref S a, ref S b) => a.value < b.value);

std/range/package.d(7180,24): Error:
__lambda2).SortedRange.dbgVerifySorted' is not nothrow
std/algorithm/sorting.d(982,29): Error: template instance
std.range.assumeSorted!(__lambda2, RangeT!(Array!(S))) error instantiating
main.d(75,9):  instantiated from here: sort!(function (ref S a, ref S b) =>
a.value < b.value, cast(SwapStrategy)0, RangeT!(Array!(S)))

Sep 20 2015