Only capture function type to address conversion

This commit is contained in:
Alex Beregszaszi 2017-02-01 12:22:14 +00:00
parent 0b61f13c7f
commit 4361797ddc

View File

@ -789,7 +789,8 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp
break;
case Type::Category::Function:
{
solAssert(targetTypeCategory == Type::Category::Integer, "Invalid conversion for function type.");
if (targetTypeCategory == Type::Category::Integer)
{
IntegerType const& targetType = dynamic_cast<IntegerType const&>(_targetType);
solAssert(targetType.isAddress(), "Function type can only be converted to address.");
FunctionType const& typeOnStack = dynamic_cast<FunctionType const&>(_typeOnStack);
@ -799,6 +800,7 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp
m_context << Instruction::POP;
break;
}
}
default:
// All other types should not be convertible to non-equal types.
solAssert(_typeOnStack == _targetType, "Invalid type conversion requested.");