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

struct in external function not compile #5581

Closed
aihuawu opened this issue Dec 4, 2018 · 5 comments
Closed

struct in external function not compile #5581

aihuawu opened this issue Dec 4, 2018 · 5 comments

Comments

@aihuawu
Copy link

aihuawu commented Dec 4, 2018

contract C
struct A {
uint256 id;
}

function f(A memory a) external {

}
}
If I change external to public, it compiles.
But it doesn't work for external

@leonardoalt
Copy link
Member

leonardoalt commented Dec 4, 2018

Hi @aihuawu , thank you for reporting!
Could you please give some more information, for example your compiler version and the error you get?
Note: in Solidity >=0.5.0, parameters of non-value type must have location calldata in external functions.
Note 2: you need pragma experimental ABIEncoderV2 to use structs as a parameter of public/external functions .
Note 3: if I'm not mistaken this is not implemented yet.

@aihuawu
Copy link
Author

aihuawu commented Dec 4, 2018

Hi, leonardoalt

pragma solidity ^ 0.4.25;
pragma experimental ABIEncoderV2;
pragma experimental "v0.5.0";

It says it is not implemented.

Unimplemented feature:
/build/solc-8UojSd/solc-0.4.25/libsolidity/codegen/ABIFunctions.cpp(1268): Throw in function std::__cxx11::string dev::solidity::ABIFunctions::abiDecodingFunctionStruct(const dev::solidity::StructType&, bool)
Dynamic exception type: boost::exception_detail::clone_impldev::solidity::UnimplementedFeatureError
std::exception::what:
[dev::tag_comment*] =

I am using interface which must be external instead of public. So I can't use public.
It would be nice if it can be implemented.

George Wu

@aihuawu
Copy link
Author

aihuawu commented Dec 4, 2018

If it is not implemented, then if I want to pass struct between contract, what should I do?

@leonardoalt
Copy link
Member

Unfortunately for now you can't receive a calldata struct (in an external function).

If you are looking for workarounds it's better to ask https://ethereum.stackexchange.com/ or https://gitter.im/ethereum/solidity.

Closing since the requested feature already has an issue: #1603

@leonardoalt
Copy link
Member

@aihuawu Maybe one thing that might help is, in Solidity 0.5.1 you can have a non-implemented interface external function that takes a calldata struct (which compiles) and override it in your contract with a public function that takes a memory struct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants