Solidity: New ABI decoder fails on arrays of dynamic types as calldata

Created on 8 Dec 2017  路  4Comments  路  Source: ethereum/solidity

pragma experimental ABIEncoderV2;

contract C {
  function f(string[]) external {}    
}

throws assertion

Internal compiler error during compilation:
/Users/alex/Projects/solidity/libsolidity/codegen/ABIFunctions.cpp(1188): Throw in function string dev::solidity::ABIFunctions::abiDecodingFunctionCalldataArray(const dev::solidity::ArrayType &)
Dynamic exception type: boost::exception_detail::clone_impl<dev::solidity::InternalCompilerError>
std::exception::what: 
[dev::tag_comment*] = 

Which means arrays of dynamic types cannot be decoded as calldata. Though changing it to public will make it working, because the decoder is invoked elsewhere.

bug

Most helpful comment

What is funny, without the ABIEncoderV2 pragma the message is:

3293.sol:4:14: Error: This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
  function f(string[] calldata) external {}    
             ^---------------^

All 4 comments

Is this maybe related to external functions handling strings a little differently in ABI encoding? See my open question: https://ethereum.stackexchange.com/questions/39418/why-do-public-and-external-functions-emit-strings-differently-in-event-logs

I posted #3493 to track that issue.

This is unimplemented mainly due to the fact that we did not yet decide how such types are stored on the stack. It was not a problem for the old decoder because it only supported one-dimensional arrays. Those are stored with two stack items: offset and size.

I guess if we know the type, it should still be possible to do that by just storing the type. Still, a lot of infrastructure is still missing - you cannot copy multi-dimensional calldata arrays to memory or storage.

After 0.5.0:

pragma experimental ABIEncoderV2;
contract C {
  function f(string[] calldata) external {}    
}
Unimplemented feature:
/Users/alex/Projectssolidity/libsolidity/codegen/ABIFunctions.cpp(1294): Throw in function std::__1::string dev::solidity::ABIFunctions::abiDecodingFunctionCalldataArray(const dev::solidity::ArrayType &)
Dynamic exception type: boost::exception_detail::clone_impl<langutil::UnimplementedFeatureError>
std::exception::what: Calldata arrays with non-value base types are not yet supported by Solidity.
[dev::tag_comment*] = Calldata arrays with non-value base types are not yet supported by Solidity.

What is funny, without the ABIEncoderV2 pragma the message is:

3293.sol:4:14: Error: This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
  function f(string[] calldata) external {}    
             ^---------------^
Was this page helpful?
0 / 5 - 0 ratings

Related issues

walter-weinmann picture walter-weinmann  路  4Comments

madvas picture madvas  路  3Comments

chriseth picture chriseth  路  3Comments

gitpusha picture gitpusha  路  3Comments

leviadam picture leviadam  路  4Comments