Bug 21453 – Struct opCmp selection does not reject ambiguous calls

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-12-04T03:17:11Z
Last change time
2024-12-13T19:13:17Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Bolpat
Moved to GitHub: dmd#19835 →

Comments

Comment #0 by qs.il.paperinik — 2020-12-04T03:17:11Z
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
Comment #1 by robert.schadek — 2024-12-13T19:13:17Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19835 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB