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

Function overload clash during conversion to external types for arguments. #4832

Closed
chriseth opened this issue Aug 16, 2018 · 8 comments · Fixed by #5445
Closed

Function overload clash during conversion to external types for arguments. #4832

chriseth opened this issue Aug 16, 2018 · 8 comments · Fixed by #5445
Labels
Projects

Comments

@chriseth
Copy link
Contributor

@chriseth chriseth commented Aug 16, 2018

// `external` keyword problem in interface 
interface FooI {
    // No problem
    function fooNum(uint num) external;

    // TypeError: Function overload clash during conversion to external types for arguments.
    function fooNums(uint[] calldata nums) external;

    // Error not thrown for no matching implementation 
    function fooNums2(uint[] calldata nums) external;
}

contract Foo is FooI {
    function fooNum(uint num) public {}
    function fooNums(uint[] memory nums) public {}
}

Found by @o0ragman0o

@chriseth chriseth added the bug 🐛 label Aug 16, 2018
@chriseth chriseth added this to Inbox in 0.5.0 via automation Aug 16, 2018
@chriseth

This comment has been minimized.

Copy link
Contributor Author

@chriseth chriseth commented Aug 16, 2018

The issue might be that the interface function (it has to be external) uses calldata while the public function uses memory - but I hope this would not be a problem, because otherwise interfaces are again useless.

@gakonst

This comment has been minimized.

Copy link

@gakonst gakonst commented Aug 22, 2018

I also get this when having two external functions in the interface with bytes:
e.g

function x(uint a, bytes b) external;
function x(uint a) external;

Overloading these with public functions causes the error you mentioned. Changing the bytes function interface to public works, but then I get the warning that interface functions must be external.

@ptagrawal

This comment has been minimized.

Copy link

@ptagrawal ptagrawal commented Aug 23, 2018

I am new to solidity, and here is my sample code.
Everytime compilation fails with the error: "TypeError: Function overload clash during conversion to external types for arguments."
on line 'function setMessage(string newMsg) external;'

`
pragma solidity ^0.4.0;
import "github.com/Arachnid/solidity-stringutils/strings.sol";

interface iInterface {
      function setMessage(string newMsg) external;
      function getMessage() external returns (string);
}

contract Contract is iInterface {
     using strings for *;

     uint private count;
     address private owner;
     string private message;



constructor (uint initialCount) public {
    count = initialCount;
    owner = msg.sender;
    message = "";
}

function incrementCount() public {
    if (owner == msg.sender) {
        count = count + 1;
    }
}

function getCount() public view returns (uint) {
    return count;
}

function kill() public {
    if (owner == msg.sender) {
        selfdestruct(owner); // Destruct the contract
    }
}

function setMessage(string newMsg) public {
    message = message.toSlice().concat(newMsg.toSlice());
}

function getMessage() public view returns (string) {
    return message;
}

}
`

@o0ragman0o

This comment has been minimized.

Copy link

@o0ragman0o o0ragman0o commented Aug 23, 2018

@axic axic moved this from Inbox to Ready to be worked on in 0.5.0 Aug 27, 2018
@leonardoalt leonardoalt self-assigned this Aug 27, 2018
sohkai added a commit to aragon/aragonOS that referenced this issue Aug 28, 2018
…lidity bug (#403)

See ethereum/solidity#4832.

There are a few other cases in our interfaces where this applies (`bytes` or array parameter in an `external` interface), but implementations of those cases shouldn't require casting the visibility to `public`:

- `IACLOracle#canPerform()`
- `IEVMScriptExecutor#execScript()`
@leonardoalt leonardoalt moved this from Ready to be worked on to Under review in 0.5.0 Aug 29, 2018
@leonardoalt leonardoalt added this to Inbox in Backlog (non-breaking) via automation Sep 5, 2018
@leonardoalt leonardoalt removed this from Under review in 0.5.0 Sep 5, 2018
@leonardoalt leonardoalt removed their assignment Nov 16, 2018
@axic axic added this to Inbox in 0.5.1 via automation Nov 16, 2018
@axic axic removed this from Inbox in Backlog (non-breaking) Nov 16, 2018
@ekpyron ekpyron moved this from Inbox to Needs review in 0.5.1 Nov 19, 2018
0.5.1 automation moved this from Needs review to Done Nov 26, 2018
@gorlitzer

This comment has been minimized.

Copy link

@gorlitzer gorlitzer commented Jan 8, 2019

Hi all, i 'm facing the same issue and have to change all the interfaces function visibility to public in order to get the warning instead of compiler error.

@chriseth

This comment has been minimized.

Copy link
Contributor Author

@chriseth chriseth commented Jan 8, 2019

@gorlitzer this should be fixed in the most recent version of the compiler. Is it still an issue for you in 0.5.2?

@gorlitzer

This comment has been minimized.

Copy link

@gorlitzer gorlitzer commented Jan 10, 2019

@chriseth yep, now it' s all right. I was using 0.5.0.

@Ferparishuertas

This comment has been minimized.

Copy link

@Ferparishuertas Ferparishuertas commented Jan 16, 2019

works!

@PaulRBerg PaulRBerg mentioned this issue Feb 13, 2019
2 of 3 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
0.5.1
  
Done
7 participants
You can’t perform that action at this time.