Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No candidates listed in ambiguous overload messages on member access #13813

Open
cameel opened this issue Dec 16, 2022 · 2 comments
Open

No candidates listed in ambiguous overload messages on member access #13813

cameel opened this issue Dec 16, 2022 · 2 comments
Labels
bug 🐛 low effort There is not much implementation work to be done. The task is very easy or tiny. low impact Changes are not very noticeable or potential benefits are limited. must have eventually Something we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.

Comments

@cameel
Copy link
Member

cameel commented Dec 16, 2022

When there's more than one matching overload for an unqualified function call, compiler lists all matching candidates. This is not the case when the function is called on an object.

Example - error for member access

contract C {
    function f(uint16) public {}
    function f(uint32) public {}

    function test() public {
        this.f(uint16(1));
    }
}
Error: Member "f" not unique after argument-dependent lookup in contract C.
 --> test.sol:6:9:
  |
6 |         this.f(uint16(1));
  |         ^^^^^^

Example - error for unqualified access

contract C {
    function f(uint16) public {}
    function f(uint32) public {}

    function test() public {
        f(uint16(1));
    }
}
Error: No unique declaration found after argument-dependent lookup.
 --> test.sol:6:9:
  |
6 |         f(uint16(1));
  |         ^
Note: Candidate:
 --> test.sol:2:5:
  |
2 |     function f(uint16) public {}
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Note: Candidate:
 --> test.sol:3:5:
  |
3 |     function f(uint32) public {}
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@cameel cameel added bug 🐛 low effort There is not much implementation work to be done. The task is very easy or tiny. low impact Changes are not very noticeable or potential benefits are limited. must have eventually Something we consider essential but not enough to prevent us from releasing Solidity 1.0 without it. labels Dec 16, 2022
@cameel cameel changed the title No candidates listed when in ambiguous overload messages on member access No candidates listed in ambiguous overload messages on member access Dec 16, 2022
@vimwitch
Copy link

Is something like this supposed to be allowed?

contract C {
    function f(uint16) public {}
    function f(uint32) public {}

    function test() public {
        f(uint16(1));
    }
}

I'm trying to use a pattern like this but can't get past the compiler error. Is the overload selection ambiguous because a uint16 can be cast to a uint32?

@cameel
Copy link
Member Author

cameel commented Jan 13, 2023

No, this overload is currently ambiguous. See #1256.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 low effort There is not much implementation work to be done. The task is very easy or tiny. low impact Changes are not very noticeable or potential benefits are limited. must have eventually Something we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.
Projects
None yet
Development

No branches or pull requests

2 participants