argotorg / argotorg/solidity

Overload resolution failure should explain for each candidate why it does not match.

Open
#9,607 10 comments 1 reaction 0 assignees View on GitHub
annoys users :cry: medium effort medium impact must have eventually
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

In the example below it is obvious we want to call the variant with the two extra parameters, but the error does not make it obvious why we can't call it (uint -> int conversion required). A better error message showing the different types would be great.

```
function checkStealing(uint _x, uint _y) private
{
CrossState[] memory stealPattern = new CrossState[](4);
[..]
for (uint i = 0; i < directions.length; i++)
{
(int xS, int yS, int xE, int yE) =
checkPattern(_x, _y, stealPattern, directions[i].x, directions[i].y); // error here
[..]
}
}

function checkPattern(int _x, int _y, CrossState[] memory _pattern,
int _xStep, int _yStep) public payable
returns(int startX, int startY, int endX, int endY)
{ [..] }

function checkPattern(int _x, int _y, CrossState[] memory _pattern) public returns(bool)
{
[...]
}

Error: No matching declaration found after argument-dependent lookup.
--> src/Game.sol:137:5:
|
137 | checkPattern(_x, _y, stealPattern, directions[i].x, directions[i].y);
| ^^^^^^^^^^^^
Note: Candidate:
--> src/Game.sol:112:2:
|
112 | function checkPattern(int _x, int _y, CrossState[] memory _pattern) public returns(bool)
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Candidate:
--> src/Game.sol:156:2:
|
156 | function checkPattern(int _x, int _y, CrossState[] memory _pattern,
| ^ (Relevant source part starts here and spans across multiple lines).
```

Contributor guide

Open the contributing guide

Research direction

Start with the overloaded checkPattern calls and declarations shown in src/Game.sol, especially the failing call at line 137. Reproduce the error and trace overload resolution to identify why each candidate is rejected; done means the diagnostic explains the relevant type mismatch for every candidate.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.