www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21453] New: Struct opCmp selection does not try rewrites

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

          Issue ID: 21453
           Summary: Struct opCmp selection does not try rewrites
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: qs.il.paperinik gmail.com

https://dlang.org/spec/operatoroverloading.html#compare says:

 Both rewrites are tried. If only one compiles,
 that one is taken. If they both resolve to the
 same function, the first rewrite is done. If
 they resolve to different functions, the best
 matching one is used. If they both match the
 same, but are different functions, an
 ambiguity error results.
This is not true. Comparison should *never ever* depend on the order of arguments, i.e. x < y should in all cases be equivalent to y > x. Programmers largely expect those to be equivalent in action the only difference being style or readability. All compilers since 2.060 accept this basic code [1] while clearly the spec says the compiler must issue an ambiguity error (and the spec is right about that). [1] https://run.dlang.io/is/V3LrEU --
Dec 03 2020