Bug 23993 – std.algorithm.maxElement no longer works with array of BigInt

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-06-15T16:11:17Z
Last change time
2023-06-28T09:48:00Z
Keywords
pull
Assigned to
No Owner
Creator
hsteoh

Comments

Comment #0 by hsteoh — 2023-06-15T16:11:17Z
Code: ---------------- import std; void main() { BigInt[] array; writeln(array.maxElement); } ---------------- Compiler output: ---------------- /usr/src/d/phobos/std/functional.d-mixin-224(224): Error: overloads `const pure nothrow @nogc @safe int(ref const(BigInt) y)` and `const pure nothrow @nogc @safe (const(Rebindable!(BigInt)) y)` both match argument list for `opCmp` /usr/src/d/phobos/std/functional.d-mixin-224(224): Error: `std.bigint.BigInt.opCmp` called with argument types `(Rebindable!(BigInt))` matches both: /usr/src/d/phobos/std/bigint.d(1065): `std.bigint.BigInt.opCmp(ref const(BigInt) y) const` and: /usr/src/d/phobos/std/bigint.d(1111): `std.bigint.BigInt.opCmp!(Rebindable!(BigInt)).opCmp(const(Rebindable!(BigInt)) y) const` /usr/src/d/phobos/std/algorithm/searching.d(1358): Error: template instance `std.functional.binaryFun!("a > b", "a", "b").binaryFun!(BigInt, Rebindable!(BigInt))` error instantiating /usr/src/d/phobos/std/algorithm/searching.d(1329): instantiated from here: `extremum!(__lambda172, "a > b", BigInt[], BigInt)` /usr/src/d/phobos/std/algorithm/searching.d(3783): instantiated from here: `extremum!(__lambda172, "a > b", BigInt[])` test.d(4): instantiated from here: `maxElement!((a) => a, BigInt[])` ---------------- Expected behaviour: the above code should compile without any errors. Retrieving the maximum element of an array of BigInt should work.
Comment #1 by hsteoh — 2023-06-15T16:17:22Z
git bisect reveals the offending commit: b818901e6351d8fb8ef75cba11df3278a0a25bcf Offending PR: https://github.com/dlang/phobos/pull/8734
Comment #2 by dlang-bot — 2023-06-15T17:07:59Z
@FeepingCreature created dlang/phobos pull request #8764 "Fix issue 23993: Discard Rebindable before passing extremum to compar…" fixing this issue: - Fix issue 23993: Discard Rebindable before passing extremum to comparator. https://github.com/dlang/phobos/pull/8764
Comment #3 by dlang-bot — 2023-06-28T09:48:00Z
dlang/phobos pull request #8764 "Fix issue 23993: Discard Rebindable before passing extremum to compar…" was merged into stable: - f715941036c10ae1664f0afa3566084f0d6ee524 by FeepingCreature: Fix issue 23993: Discard Rebindable before passing extremum to comparator. https://github.com/dlang/phobos/pull/8764