|
|
@ -338,7 +338,14 @@ void FunctionDefinition::checkTypeRequirements() |
|
|
|
if (!var->getType()->canLiveOutsideStorage()) |
|
|
|
BOOST_THROW_EXCEPTION(var->createTypeError("Type is required to live outside storage.")); |
|
|
|
if (getVisibility() >= Visibility::Public && !(var->getType()->externalType())) |
|
|
|
BOOST_THROW_EXCEPTION(var->createTypeError("Internal type is not allowed for function with external visibility")); |
|
|
|
{ |
|
|
|
// todo delete when arrays as parameter type in internal functions will be implemented
|
|
|
|
ArrayType const* type = dynamic_cast<ArrayType const*>(var->getType().get()); |
|
|
|
if (getVisibility() == Visibility::Public && type) |
|
|
|
BOOST_THROW_EXCEPTION(var->createTypeError("Array type is not allowed as parameter for internal functions.")); |
|
|
|
else |
|
|
|
BOOST_THROW_EXCEPTION(var->createTypeError("Internal type is not allowed for function with external visibility.")); |
|
|
|
} |
|
|
|
} |
|
|
|
for (ASTPointer<ModifierInvocation> const& modifier: m_functionModifiers) |
|
|
|
modifier->checkTypeRequirements(isConstructor() ? |
|
|
@ -379,6 +386,14 @@ void VariableDeclaration::checkTypeRequirements() |
|
|
|
m_value->expectType(*m_type); |
|
|
|
if (m_isStateVariable && !m_type->externalType() && getVisibility() >= Visibility::Public) |
|
|
|
BOOST_THROW_EXCEPTION(createTypeError("Internal type is not allowed for state variables.")); |
|
|
|
|
|
|
|
auto sharedToExternalTypes = FunctionType(*this).externalType(); // do not distroy the shared pointer.
|
|
|
|
auto externalFunctionTypes = dynamic_cast<FunctionType const*>(sharedToExternalTypes.get()); |
|
|
|
TypePointers retParamTypes = externalFunctionTypes->getReturnParameterTypes(); |
|
|
|
TypePointers parameterTypes = externalFunctionTypes->getParameterTypes(); |
|
|
|
for (auto parameter: parameterTypes + retParamTypes) |
|
|
|
if (!parameter && !(parameter->externalType())) |
|
|
|
BOOST_THROW_EXCEPTION(createTypeError("Internal type is not allowed for state variables.")); |
|
|
|
} else |
|
|
|
{ |
|
|
|
// no type declared and no previous assignment, infer the type
|
|
|
|