0

Remix Error: Type error, Return argument type inaccessible dynamic type is not implicitly convertible to expected type (type of first return variable) bytes32[]

snippet code shown below: Do take note I didnt include the setter function.

enter code here


pragma solidity ^0.4.18;
contract DeployedContract {

struct emailNetworkLists {
     bytes32[] emailArray;
}

struct Namecards{
    address ethAddress;
    bytes32 personName;
    bytes32 designation;
    bytes32 companyName;
    bytes32 comaddress;
    bytes32 emailId;
    bytes32 mobNumber;
    bytes32 date;
    bool isActive;
    uint index;
    mapping(bytes32=> emailNetworkLists) contactList;
}

bytes32[] public addressList;
mapping(bytes32 => Namecards) public nameStructMapping;

function getEmails(bytes32 email, bytes32 date) public view returns(bytes32[]){
    return (nameStructMapping[email].contactList[date].emailArray);
}

}

contract External {
    DeployedContract d = DeployedContract(0xe90f4f8ae................);
    function getEmailList(bytes32 email, bytes32 date) public view returns(bytes32[] ){ //error here on Remix
       return (d.getEmails(email, date));
    }
}

1 Answer 1

1

It's complaining because you're trying to return dynamic arrays. That isn't supported by the protocol until after Byzantium and solc 0.4.22.

Refactor for and compile with solc 0.4.24 and things should work out.

I modified External's constructor to create a new Deployed contract to get it testable condition. Seems to work. No warranty ;-)

pragma solidity ^0.4.24;
contract DeployedContract {

    struct emailNetworkLists {
         bytes32[] emailArray;
    }

    struct Namecards{
        address ethAddress;
        bytes32 personName;
        bytes32 designation;
        bytes32 companyName;
        bytes32 comaddress;
        bytes32 emailId;
        bytes32 mobNumber;
        bytes32 date;
        bool isActive;
        uint index;
        mapping(bytes32=> emailNetworkLists) contactList;
    }

    bytes32[] public addressList;
    mapping(bytes32 => Namecards) public nameStructMapping;

    function getEmails(bytes32 email, bytes32 date) public view returns(bytes32[]){
        return (nameStructMapping[email].contactList[date].emailArray);
    }

}

contract External {

    DeployedContract d;

    constructor() public {
        d = new DeployedContract();
    }

    function getEmailList(bytes32 email, bytes32 date) public view returns(bytes32[] ){
       return (d.getEmails(email, date));
    }
}

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.