Fix Issue 10317 - Remove text(range) check and avoid recursive instantiation bug.

This commit is contained in:
Andrej Mitrovic 2013-06-10 04:45:29 +02:00
parent e9d5202062
commit 8f5f220194

View file

@ -8127,17 +8127,12 @@ sort(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable,
quickSortImpl!(lessFun)(r); quickSortImpl!(lessFun)(r);
else //use Tim Sort for semistable & stable else //use Tim Sort for semistable & stable
TimSortImpl!(lessFun, Range).sort(r, null); TimSortImpl!(lessFun, Range).sort(r, null);
static if (is(typeof(text(r))))
{ enum maxLen = 8;
enum maxLen = 8; assert(isSorted!lessFun(r), text("Failed to sort range of type ",
assert(isSorted!lessFun(r), text("Failed to sort range of type ", Range.stringof, ". Actual result is: ",
Range.stringof, ". Actual result is: ", r[0 .. r.length > maxLen ? maxLen : r.length ],
r[0 .. r.length > maxLen ? maxLen : r.length ], r.length > maxLen ? "..." : ""));
r.length > maxLen ? "..." : ""));
}
else
assert(isSorted!lessFun(r), text("Unable to sort range of type ",
Range.stringof, ": <unable to print elements>"));
} }
else else
{ {
@ -8190,6 +8185,13 @@ unittest
auto b = rndstuff!(string)(); auto b = rndstuff!(string)();
sort!("toLower(a) < toLower(b)")(b); sort!("toLower(a) < toLower(b)")(b);
assert(isSorted!("toUpper(a) < toUpper(b)")(b)); assert(isSorted!("toUpper(a) < toUpper(b)")(b));
{
// Issue 10317
enum E_10317 { a, b }
auto a_10317 = new E_10317[10];
sort(a_10317);
}
} }
private template validPredicates(E, less...) { private template validPredicates(E, less...) {