diff options
author | chriseth <c@ethdev.com> | 2016-01-18 16:23:21 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-01-18 16:23:21 +0800 |
commit | 2c5d045729f375ba386083dfd305f186d6d8577a (patch) | |
tree | 6479be15b7dac20801d4f268b6b264d4b62a96c1 | |
parent | cc4b4f507784d67a7f53c5cbaee5a99fc6fe9e2d (diff) | |
parent | 9613a94153c834432688577e9cfdb2328eeae691 (diff) | |
download | dexon-solidity-2c5d045729f375ba386083dfd305f186d6d8577a.tar.gz dexon-solidity-2c5d045729f375ba386083dfd305f186d6d8577a.tar.zst dexon-solidity-2c5d045729f375ba386083dfd305f186d6d8577a.zip |
Merge pull request #359 from LianaHus/sol_only_one_array_as_state_var
fixed ICError when creating EI for structs containing only mapping or arrays
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 16 | ||||
-rw-r--r-- | libsolidity/ast/Types.cpp | 4 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 11 |
3 files changed, 25 insertions, 6 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index ab1151a1..69357043 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -292,17 +292,21 @@ void TypeChecker::checkContractExternalTypeClashes(ContractDefinition const& _co if (f->isPartOfExternalInterface()) { auto functionType = make_shared<FunctionType>(*f); - externalDeclarations[functionType->externalSignature()].push_back( - make_pair(f, functionType) - ); + // under non error circumstances this should be true + if (functionType->interfaceFunctionType()) + externalDeclarations[functionType->externalSignature()].push_back( + make_pair(f, functionType) + ); } for (VariableDeclaration const* v: contract->stateVariables()) if (v->isPartOfExternalInterface()) { auto functionType = make_shared<FunctionType>(*v); - externalDeclarations[functionType->externalSignature()].push_back( - make_pair(v, functionType) - ); + // under non error circumstances this should be true + if (functionType->interfaceFunctionType()) + externalDeclarations[functionType->externalSignature()].push_back( + make_pair(v, functionType) + ); } } for (auto const& it: externalDeclarations) diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 2e9b56a1..79e5bb02 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -1593,6 +1593,10 @@ FunctionTypePointer FunctionType::interfaceFunctionType() const else return FunctionTypePointer(); } + auto variable = dynamic_cast<VariableDeclaration const*>(m_declaration); + if (variable && retParamTypes.empty()) + return FunctionTypePointer(); + return make_shared<FunctionType>(paramTypes, retParamTypes, m_parameterNames, m_returnParameterNames, m_location, m_arbitraryParameters); } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 4697e756..7e030c7f 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -1003,6 +1003,17 @@ BOOST_AUTO_TEST_CASE(base_class_state_variable_accessor) BOOST_CHECK(success(text)); } +BOOST_AUTO_TEST_CASE(struct_accessor_one_array_only) +{ + char const* sourceCode = R"( + contract test { + struct Data { uint[15] m_array; } + Data public data; + } + )"; + BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); +} + BOOST_AUTO_TEST_CASE(base_class_state_variable_internal_member) { char const* text = "contract Parent {\n" |