don't consider inserted default values in overload disambiguation #24232
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
refs status-im/nimbus-eth1#2684 (comment)
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 emptyvarargs
generated at the end of the match is also marked asnfDefaultParam
. We could rename this tonfInsertedParam
, butupdateDefaultParams
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 likeNotInserted, InsertedDefaultParam, InsertedVarargs
, in which case we don't neednfDefaultParam
at all. Let me know if this should be done instead.