Bug 24697 – Function overload resolution is vague and incomplete

Status
NEW
Severity
normal
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-08-06T17:08:34Z
Last change time
2024-12-15T15:28:29Z
Assigned to
No Owner
Creator
Bolpat
Moved to GitHub: dlang.org#4145 →

Comments

Comment #0 by qs.il.paperinik — 2024-08-06T17:08:34Z
Relevant section: https://dlang.org/spec/function.html#function-overloading - It is unclear what is meant by implicit conversions and if all implicit conversions are equal. - It is unclear what is meant by a qualifier conversion (does it include lvalue to rvalue conversion? What about @safe to @system conversion?) - It is even unclear what exactly an exact match is (again, is lvalue to rvalue conversion an exact match) - It is unclear what “(including any this reference)” means exactly. - It is not stated if function attributes (on the called function) affect overload resolution - “Literals do not match `ref` or `out` parameters.” Is not incorrect, but misleading. In general, rvalues are not literals, and it’s them who can’t bind to `ref` and `out`. - “`scope` parameter storage class does not affect function overloading.” (Bad grammar.) Okay, what about other parameter storage classes? There are `auto` (for `auto ref`), `final` (can indeed be ignored), `in`, `lazy`, `out`, `ref`, `return`, and `scope`, also user-defined ones. The effect of each of them (except `final`) must be specified. - The `-preview=rvaluerefparam` preview switch is not accounted for. - The `-preview=in` switch is not accounted for. There are the following implicit conversions: - integral conversion from a smaller-range type to a bigger one. - derived class to base class/interface - alias this - lvalue to rvalue - rvalue to lvalue (for `in` under preview) - Weakening of attributes for function pointer and delegate types - qualifier conversions It may in fact be desirable to vet each of those individually and first judge then explain in the spec whether they fall into match level 2 or 3. E.g. it seems value category is considered by DMD akin to a qualifier, i.e. lvalue to rvalue conversion is not considered an implicit conversion. Under the `in` preview, overload resolution is affected by whether the argument is bound by reference. IMO, matching against `in` should not depend on that. Possibly, lvalue to rvalue conversion deserves its own matching level.
Comment #1 by robert.schadek — 2024-12-15T15:28:29Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dlang.org/issues/4145 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB