implicit cast and overload priority

Dom DiSc dominikus at scherkl.de
Sat Feb 15 15:40:51 UTC 2025


On Friday, 14 February 2025 at 15:58:26 UTC, Paul Backus wrote:

> In your example, both overloads have match level 2: "match with 
> implicit conversions". So the compiler attempts to figure out 
> which one is more specialized by checking whether the 
> parameters of one overload can be used to call the other 
> overload.

Yes. But there could be another level (2b?) "match with implicit 
conversion and signedness change", as new tiebreaker.
This would be really easy to implement, and I can't see it 
causing any problems, as it would only allow to distinguish 
things that are today an error. So no code breakage.

> Oops--it turns out both overloads are equally specialized!

This is what I want to be fixed. For a human it is obvious which 
of the two is a better match. Lets add a rule so that the 
compiler can also see it!




More information about the Digitalmars-d-learn mailing list