@ -337,8 +337,14 @@ void FunctionDefinition::checkTypeRequirements()
{
{
if ( ! var - > getType ( ) - > canLiveOutsideStorage ( ) )
if ( ! var - > getType ( ) - > canLiveOutsideStorage ( ) )
BOOST_THROW_EXCEPTION ( var - > createTypeError ( " Type is required to live outside storage. " ) ) ;
BOOST_THROW_EXCEPTION ( var - > createTypeError ( " Type is required to live outside storage. " ) ) ;
if ( ! ( var - > getType ( ) - > externalType ( ) ) & & getVisibility ( ) > = Visibility : : Public )
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 will be implemented arrays as parameter type in internal functions
if ( getVisibility ( ) = = Visibility : : Public & & var - > getType ( ) - > getCategory ( ) = = Type : : Category : : Array )
BOOST_THROW_EXCEPTION ( var - > createTypeError ( " Arrays only implemented for external functions. " ) ) ;
else
BOOST_THROW_EXCEPTION ( var - > createTypeError ( " Internal type is not allowed for public and external functions. " ) ) ;
}
}
}
for ( ASTPointer < ModifierInvocation > const & modifier : m_functionModifiers )
for ( ASTPointer < ModifierInvocation > const & modifier : m_functionModifiers )
modifier - > checkTypeRequirements ( isConstructor ( ) ?
modifier - > checkTypeRequirements ( isConstructor ( ) ?
@ -379,7 +385,11 @@ void VariableDeclaration::checkTypeRequirements()
m_value - > expectType ( * m_type ) ;
m_value - > expectType ( * m_type ) ;
if ( m_isStateVariable & & ! m_type - > externalType ( ) & & getVisibility ( ) > = Visibility : : Public )
if ( m_isStateVariable & & ! m_type - > externalType ( ) & & getVisibility ( ) > = Visibility : : Public )
BOOST_THROW_EXCEPTION ( createTypeError ( " Internal type is not allowed for state variables. " ) ) ;
BOOST_THROW_EXCEPTION ( createTypeError ( " Internal type is not allowed for state variables. " ) ) ;
} else
if ( ! FunctionType ( * this ) . externalType ( ) )
BOOST_THROW_EXCEPTION ( createTypeError ( " Internal type is not allowed for public state variables. " ) ) ;
}
else
{
{
// no type declared and no previous assignment, infer the type
// no type declared and no previous assignment, infer the type
m_value - > checkTypeRequirements ( ) ;
m_value - > checkTypeRequirements ( ) ;