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,18 +8127,13 @@ sort(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable,
quickSortImpl!(lessFun)(r);
else //use Tim Sort for semistable & stable
TimSortImpl!(lessFun, Range).sort(r, null);
static if (is(typeof(text(r))))
{
enum maxLen = 8;
assert(isSorted!lessFun(r), text("Failed to sort range of type ",
Range.stringof, ". Actual result is: ",
r[0 .. r.length > maxLen ? maxLen : r.length ],
r.length > maxLen ? "..." : ""));
}
else
assert(isSorted!lessFun(r), text("Unable to sort range of type ",
Range.stringof, ": <unable to print elements>"));
}
else
{
static assert(false, "Invalid predicate passed to sort: "~less);
@ -8190,6 +8185,13 @@ unittest
auto b = rndstuff!(string)();
sort!("toLower(a) < toLower(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...) {