Solidity: Function overload clash during conversion to external types for arguments.

Created on 16 Aug 2018  Â·  8Comments  Â·  Source: ethereum/solidity

// `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

bug

Most helpful comment

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

All 8 comments

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.

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.

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;
}

}
`

It appears to be an issue with unbound parameter types (string, bytes, [],
etc). Interfaces have never been useful in my experience and you are
better to use contract abstracts instead for API declaration.

On 23 August 2018 at 17:18, Paritosh Agrawal notifications@github.com
wrote:

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;
}

}

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/ethereum/solidity/issues/4832#issuecomment-415316783,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMMqOhZhEsmVEe9oWTdfGFFa7JSf-yIjks5uTldUgaJpZM4V_eC0
.

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.

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

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

works!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Dohtar1337 picture Dohtar1337  Â·  4Comments

VoR0220 picture VoR0220  Â·  4Comments

hiqua picture hiqua  Â·  4Comments

chriseth picture chriseth  Â·  3Comments

ddeclerck picture ddeclerck  Â·  3Comments