diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-03-06 22:51:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-06 22:51:17 +0800 |
commit | 83dacbf669f58ad40e3035837d4ea8a846c46949 (patch) | |
tree | f9f2f1fd434fbe1949bd6f9407ecd62bae47c8fe /libsolidity/analysis | |
parent | 0df4c64884d1b8d3695dd59de5f828ba5298b313 (diff) | |
parent | 98e8a9385456b5d3fe3ca7ef2e0c923b0aab2ea3 (diff) | |
download | dexon-solidity-83dacbf669f58ad40e3035837d4ea8a846c46949.tar.gz dexon-solidity-83dacbf669f58ad40e3035837d4ea8a846c46949.tar.zst dexon-solidity-83dacbf669f58ad40e3035837d4ea8a846c46949.zip |
Merge pull request #3549 from ethereum/fixmultidim
Properly detect which array and struct types are unsupported by the old ABI encoder.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 9846a0d0..1748b518 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -34,6 +34,29 @@ using namespace std; using namespace dev; using namespace dev::solidity; +namespace +{ + +bool typeSupportedByOldABIEncoder(Type const& _type) +{ + if (_type.dataStoredIn(DataLocation::Storage)) + return true; + else if (_type.category() == Type::Category::Struct) + return false; + else if (_type.category() == Type::Category::Array) + { + auto const& arrayType = dynamic_cast<ArrayType const&>(_type); + auto base = arrayType.baseType(); + if (!typeSupportedByOldABIEncoder(*base)) + return false; + else if (base->category() == Type::Category::Array && base->isDynamicallySized()) + return false; + } + return true; +} + +} + bool TypeChecker::checkTypeRequirements(ASTNode const& _contract) { @@ -561,13 +584,12 @@ bool TypeChecker::visit(FunctionDefinition const& _function) m_errorReporter.fatalTypeError(var->location(), "Internal or recursive type is not allowed for public or external functions."); if ( _function.visibility() > FunctionDefinition::Visibility::Internal && - type(*var)->category() == Type::Category::Struct && - !type(*var)->dataStoredIn(DataLocation::Storage) && - !_function.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::ABIEncoderV2) + !_function.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::ABIEncoderV2) && + !typeSupportedByOldABIEncoder(*type(*var)) ) m_errorReporter.typeError( var->location(), - "Structs are only supported in the new experimental ABI encoder. " + "This type is only supported in the new experimental ABI encoder. " "Use \"pragma experimental ABIEncoderV2;\" to enable the feature." ); |