More detail about candidates in error messages for ambiguous overloaded calls #13812
Labels
annoys users 😢
medium effort
Default level of effort
medium impact
Default level of impact
must have eventually
Something we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.
This came up recently on the forum: Why are implicit string to bytes conversions allowed in external calls but not internally?
Errors that the compiler reports when there is more than one candidate for an overload but none of them is quite right don't have enough detail to make it clear to the user why they don't match. The error is just
No unique declaration found after argument-dependent lookup
and a list of candidates.When there is exactly one candidate, the compiler type-checks its arguments and says what exactly is wrong: too many arguments, no implicit conversion, etc. The same information should be printed for each candidate in case where there's more than one.
Note that the same mechanism should separately be applied to user-defined operators as well, since for them overloading is still possible but works differently than for functions (#13790/#13718).
Example - multiple candidates
The compiler points out the problem and candidates but does not explain what's wrong with each of them. Especially in this example the second and third overload look like they should match and it may be hard to figure out why they don't.
Example - one candidate
For each candidate in insolation you get a much clearer message:
function f() public {}
function f(bytes4) public {}
function f(bytes calldata) public {}
The text was updated successfully, but these errors were encountered: