www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15230] New: Inconsistent std.range.SortedRange predicate checks


          Issue ID: 15230
           Summary: Inconsistent std.range.SortedRange predicate checks
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: john.loughran.colvin gmail.com

SortedRange doesn't check that it's predicate actually works unless you use one
of lowerbound, upperBound etc. or you compile with -debug, in which case things
will fail internally to std.functional.binaryFun due to the usage of the
predicate in dbgVerifySorted.

Note that people could be signalling sorted-ness using SortedRange, not
considering they have invalid predicates, e.g.

struct S { int a,b; }
void foo(R)(R r)
if(isInstanceOf!(SortedRange, P) && is(ElementType!R == S))
    //assumes some idea of sorted-ness
only(S(0,1), S(0,4), S(3,4), S(4,4)).assumeSorted.foo();

but I guess it's OK to break that because it was technically incorrect, if
rather opaquely so....

Oct 21 2015