Disallow payable internal functions.

This commit is contained in:
chriseth
2016-11-16 14:37:18 +01:00
parent f7a62c1e69
commit 925d674146
3 changed files with 41 additions and 2 deletions
+2 -1
View File
@@ -95,7 +95,8 @@ void ReferencesResolver::endVisit(FunctionTypeName const& _typeName)
typeError(_typeName.location(), "Invalid visibility, can only be \"external\" or \"internal\".");
}
// Do we allow storage references for external functions?
if (_typeName.isPayable() && _typeName.visibility() != VariableDeclaration::Visibility::External)
fatalTypeError(_typeName.location(), "Only external function types can be payable.");
_typeName.annotation().type = make_shared<FunctionType>(_typeName);
}
+3 -1
View File
@@ -1704,7 +1704,7 @@ TypePointer TupleType::closestTemporaryType(TypePointer const& _targetType) cons
FunctionType::FunctionType(FunctionDefinition const& _function, bool _isInternal):
m_location(_isInternal ? Location::Internal : Location::External),
m_isConstant(_function.isDeclaredConst()),
m_isPayable(_function.isPayable()),
m_isPayable(_isInternal ? false : _function.isPayable()),
m_declaration(&_function)
{
TypePointers params;
@@ -1810,6 +1810,8 @@ FunctionType::FunctionType(FunctionTypeName const& _typeName):
m_isConstant(_typeName.isDeclaredConst()),
m_isPayable(_typeName.isPayable())
{
if (_typeName.isPayable())
solAssert(m_location == Location::External, "Internal payable function type used.");
for (auto const& t: _typeName.parameterTypes())
{
solAssert(t->annotation().type, "Type not set for parameter.");