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
This commit is contained in:
chriseth 2016-01-18 09:23:21 +01:00
commit 2c5d045729
3 changed files with 25 additions and 6 deletions

View File

@ -292,6 +292,8 @@ void TypeChecker::checkContractExternalTypeClashes(ContractDefinition const& _co
if (f->isPartOfExternalInterface()) if (f->isPartOfExternalInterface())
{ {
auto functionType = make_shared<FunctionType>(*f); auto functionType = make_shared<FunctionType>(*f);
// under non error circumstances this should be true
if (functionType->interfaceFunctionType())
externalDeclarations[functionType->externalSignature()].push_back( externalDeclarations[functionType->externalSignature()].push_back(
make_pair(f, functionType) make_pair(f, functionType)
); );
@ -300,6 +302,8 @@ void TypeChecker::checkContractExternalTypeClashes(ContractDefinition const& _co
if (v->isPartOfExternalInterface()) if (v->isPartOfExternalInterface())
{ {
auto functionType = make_shared<FunctionType>(*v); auto functionType = make_shared<FunctionType>(*v);
// under non error circumstances this should be true
if (functionType->interfaceFunctionType())
externalDeclarations[functionType->externalSignature()].push_back( externalDeclarations[functionType->externalSignature()].push_back(
make_pair(v, functionType) make_pair(v, functionType)
); );

View File

@ -1593,6 +1593,10 @@ FunctionTypePointer FunctionType::interfaceFunctionType() const
else else
return FunctionTypePointer(); 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); return make_shared<FunctionType>(paramTypes, retParamTypes, m_parameterNames, m_returnParameterNames, m_location, m_arbitraryParameters);
} }

View File

@ -1003,6 +1003,17 @@ BOOST_AUTO_TEST_CASE(base_class_state_variable_accessor)
BOOST_CHECK(success(text)); 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) BOOST_AUTO_TEST_CASE(base_class_state_variable_internal_member)
{ {
char const* text = "contract Parent {\n" char const* text = "contract Parent {\n"