[Issue 24858] maxIndex but not minIndex sometimes returns the index as an array with a single element
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 15 13:27:18 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24858
--- Comment #3 from pabuond at gmail.com ---
Aw, my bad - I was doing some tests, but in combination with mir.ndslice and it
turns out it's due to a clash with mir.ndslice's maxIndex/minIndex that I
didn't realise I was importing too. So not a bug in std.algorithm :) sorry for
the false alarm! Not too sure exactly what creates the issue, some import
combinations work, but one doesn't. (Of course, it's bad to import homonyms
into the namespace - the compiler seemed to deal with it, so I thought it was
fine, but obviously it creates some issues. There doesn't seem to be a way to
use UFCS with full module names, is there?)
```
import std.stdio: writeln;
import std.math: fabs;
/* OK */
// import std.algorithm: maxIndex, minIndex, map;
/* OK */
// import std.algorithm: maxIndex, minIndex;
// import mir.ndslice: map;
/* OK */
// import std.algorithm: maxIndex, minIndex, map;
// import mir.ndslice: maxIndex, minIndex;
/* Not OK */
import std.algorithm: maxIndex, minIndex;
import mir.ndslice: maxIndex, minIndex, map;
void main()
{
double[] u = [-9, 3, 2, 8, 4];
writeln(u.maxIndex); // => 3, OK
writeln(u.minIndex); // => 0, OK
writeln(u.map!fabs.minIndex); // => [2] ???
writeln(u.map!fabs.maxIndex); // => [0] ???
}
```
--
More information about the Digitalmars-d-bugs
mailing list