Comment #0 by default_357-line — 2020-08-21T10:28:40Z
Consider the following code:
import std.algorithm : schwartzSort;
import std.array : array;
struct S
{
int i;
const(int) foo() { return i; }
}
void main()
{
auto list = [S(4), S(3), S(2)];
assert(list.dup.schwartzSort!(a => a.foo).array == [S(2), S(3), S(4)]);
}
This leads to cryptic errors due to the fact that `schwartzSort` does not strip the `const` from `const(int)` for its internal array, even though it trivially could since it's a value type.
Comment #1 by dlang-bot — 2020-08-21T12:26:58Z
@MoonlightSentinel created dlang/phobos pull request #7602 "Fix Issue 21183 - schwartzSort does not strip const" fixing this issue:
- Fix Issue 21183 - schwartzSort does not strip const
Fixed by using the unqualified type if possible
https://github.com/dlang/phobos/pull/7602
Comment #2 by dlang-bot — 2020-08-21T16:43:14Z
dlang/phobos pull request #7602 "Fix Issue 21183 - schwartzSort does not strip const" was merged into stable:
- 255f9496d1ef72876613d27341dee483e364aa3d by MoonlightSentinel:
Fix Issue 21183 - schwartzSort does not strip const
Fixed by using the unqualified type if possible
https://github.com/dlang/phobos/pull/7602