Remove version(assert) from TimSort

If `-debug` is passed to the compiler, `version(assert)` is true.
TimSort has a `version(assert)` that checks some invariants, and uses
std.format.format for better error messages. Unfortunately, since it
is templated code, this results in Phobos template instantiations of
`format` in the user's code when `-debug` is used.

Given that default dub builds use `-debug`, this is a very common
problem.

Instead of removing the invariant checks, this changes it so they only
happen when testing Phobos itself.
This commit is contained in:
Atila Neves 2020-04-09 19:06:35 +02:00
parent 0300b493f4
commit 85aede0639

View file

@ -2332,7 +2332,7 @@ private template TimSortImpl(alias pred, R)
}
// Assert that the code above established the invariant correctly
version (assert)
version (StdUnittest)
{
if (stackLen == 2)
{