[Issue 21109] Wrong result when using sort() on enum arrays

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Aug 7 08:50:57 UTC 2020


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

Simen Kjaeraas <simen.kjaras at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras at gmail.com

--- Comment #7 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
We can reduce this issue down to this code:

struct S {
    int[] arr;
}

unittest {
    import std.stdio;
    foreach (idx; 0 .. 10) {
        writeln([S([0])] < [S([0])]);
    }
}

I'm not convinced that being able to compare two arrays like this should be
possible at all - the rule that for any T where T.init < T.init does not
compile, [T.init] < [T.init] should not compile seems sensible to me.

If we need it to work, it should definitely do a member-by-member comparison.
Not least, this should be documented.

--


More information about the Digitalmars-d-bugs mailing list