diff options
author | chriseth <chris@ethereum.org> | 2018-08-16 21:56:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-16 21:56:14 +0800 |
commit | 410d288dfc2e08c42df58c7e01ad5c332ce92727 (patch) | |
tree | 8a905ac23df94b0df2f2dd1a0b6b6dfbf5b58008 /libsolidity | |
parent | 146e89c2ec795ae799a91b54a959e672a998b8f9 (diff) | |
parent | 583e7156ba214c98096217d18f6270e4a46491d9 (diff) | |
download | dexon-solidity-410d288dfc2e08c42df58c7e01ad5c332ce92727.tar.gz dexon-solidity-410d288dfc2e08c42df58c7e01ad5c332ce92727.tar.zst dexon-solidity-410d288dfc2e08c42df58c7e01ad5c332ce92727.zip |
Merge pull request #4629 from ethereum/mapping_dynamic_key
Dynamic type as mapping key returns error instead of assertion fail
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 5033fd63..fca64f6a 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -819,7 +819,9 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) ) m_errorReporter.typeError(_variable.location(), "Internal or recursive type is not allowed for public state variables."); - if (varType->category() == Type::Category::Array) + switch (varType->category()) + { + case Type::Category::Array: if (auto arrayType = dynamic_cast<ArrayType const*>(varType.get())) if ( ((arrayType->location() == DataLocation::Memory) || @@ -827,6 +829,18 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) !arrayType->validForCalldata() ) m_errorReporter.typeError(_variable.location(), "Array is too large to be encoded."); + break; + case Type::Category::Mapping: + if (auto mappingType = dynamic_cast<MappingType const*>(varType.get())) + if ( + mappingType->keyType()->isDynamicallySized() && + _variable.visibility() == Declaration::Visibility::Public + ) + m_errorReporter.typeError(_variable.location(), "Dynamically-sized keys for public mappings are not supported."); + break; + default: + break; + } return false; } |