[Issue 19828] maxElement give wrong results
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Apr 26 08:36:38 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19828
--- Comment #1 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
This issue boils down to this line in std.algorithm.searching:
static if (__traits(isSame, map, a => a))
For some reason, that returns true for some lambdas that are absolutely not
identical. Reduced version:
import std.stdio : writeln;
unittest {
int[] arr = [0, 1];
// Different.
writeln(__traits(isSame, i => arr[i], a => a) ? "Same" : "Different");
// Same.
test!(i => arr[i], a => a);
// Different.
test!(i => arr[i], a => a * 4);
}
auto test(alias map1, alias map2)() {
writeln(__traits(isSame, map1, map2) ? "Same" : "Different");
}
Filed that as a separate issue 19829 as this can be fixed in Phobos without
fixing DMD.
--
More information about the Digitalmars-d-bugs
mailing list