fix: resolve overloaded methods by argument type, not just count - #2800
Open
beardthelion wants to merge 1 commit into
Open
fix: resolve overloaded methods by argument type, not just count#2800beardthelion wants to merge 1 commit into
beardthelion wants to merge 1 commit into
Conversation
Calling an overloaded method whose overloads share the same argument count (e.g. getUpdateFee(bytes[]) and getUpdateFee(uint256)) failed with a ConversionError instead of using the overload the arguments fit. _select_method_abi selected by argument count alone and, among equal-count candidates, kept the last declared, with no type check. So a list (valid for bytes[], not uint256) was routed to the uint256 overload and failed at encode time. Make selection type-aware: when more than one overload matches the count, pick the first whose input types the args encode to, otherwise keep the previous behavior. Encoding is pure, so the probe adds no network calls. Closes ApeWorX#2670
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Calling an overloaded method whose overloads share the same argument count (e.g.
getUpdateFee(bytes[])andgetUpdateFee(uint256)) failed withConversionError: No conversion registered to handle '[]'instead of using the overload the arguments fit._select_method_abiselected by argument count alone and, among equal-count candidates, kept the last one declared, with no type check. So a list argument (valid forbytes[], notuint256) was routed to theuint256overload and failed at encode time.This makes selection type-aware: when more than one overload matches the argument count, it picks the first whose input types the arguments encode to, and otherwise keeps the previous behavior (single candidate, no probe, or none fits). Encoding is pure, so the probe adds no network calls. The
multicallcaller, which does not pass the probe, is unaffected.Validation:
tests/functional/test_contract_instance.py: an overloaded method with same-countbytes[]anduint256overloads selectsbytes[]for a list argument, in both declaration orders.Closes #2670