Nim icon indicating copy to clipboard operation
Nim copied to clipboard

don't consider inserted default values in overload disambiguation

Open metagn opened this issue 1 year ago • 2 comments

refs https://github.com/status-im/nimbus-eth1/pull/2684#issuecomment-2392895327

In overload disambiguation, the entire proc types of the overloads are compared to each other, including the types of parameters that aren't in the original call. To fix this, we make the "specificity" value of inserted params like default values or empty varargs equal to 0, which acts as if they weren't there at all.

To check for inserted params the nfDefaultParam node flag is used, and now empty varargs generated at the end of the match is also marked as nfDefaultParam. We could rename this to nfInsertedParam, but updateDefaultParams had to be changed to a way that happens to work with varargs (checking if the param has a default value, only works because varargs can't have default values), so it's not necessarily that general.

An alternative is to track the insertedness of arguments as an array inside TCandidate, as an enum with values like NotInserted, InsertedDefaultParam, InsertedVarargs, in which case we don't need nfDefaultParam at all. Let me know if this should be done instead.

metagn avatar Oct 04 '24 07:10 metagn

This pull request is stale because it has been open for 1 year with no activity. Contribute more commits on the pull request and rebase it on the latest devel, or it will be closed in 30 days. Thank you for your contributions.

github-actions[bot] avatar Oct 05 '25 00:10 github-actions[bot]

I don't see how that's intuitive behavior. IMO it's pretty much guesswork here for the programmer.

Araq avatar Oct 07 '25 12:10 Araq