www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23993] New: std.algorithm.maxElement no longer works with

https://issues.dlang.org/show_bug.cgi?id=23993

          Issue ID: 23993
           Summary: std.algorithm.maxElement no longer works with array of
                    BigInt
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: hsteoh qfbox.info

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.

--
Jun 15 2023