Skip to content

fix: resolve overloaded methods by argument type, not just count - #2800

Open
beardthelion wants to merge 1 commit into
ApeWorX:mainfrom
beardthelion:fix/overloaded-method-arg-type-selection
Open

fix: resolve overloaded methods by argument type, not just count#2800
beardthelion wants to merge 1 commit into
ApeWorX:mainfrom
beardthelion:fix/overloaded-method-arg-type-selection

Conversation

@beardthelion

Copy link
Copy Markdown

Calling an overloaded method whose overloads share the same argument count (e.g. getUpdateFee(bytes[]) and getUpdateFee(uint256)) failed with ConversionError: No conversion registered to handle '[]' instead of using the overload the arguments fit.

_select_method_abi selected by argument count alone and, among equal-count candidates, kept the last one declared, with no type check. So a list argument (valid for bytes[], not uint256) was routed to the uint256 overload 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 multicall caller, which does not pass the probe, is unaffected.

Validation:

  • New test in tests/functional/test_contract_instance.py: an overloaded method with same-count bytes[] and uint256 overloads selects bytes[] for a list argument, in both declaration orders.

Closes #2670

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conversion error when two different data types are accepted for args

1 participant