ast, codegen: disallow conversion between different enum types

This commit is contained in:
Yoichi Hirai 2016-11-09 17:02:25 +01:00
parent 4b6e7e0677
commit 20c2ca3992
No known key found for this signature in database
GPG Key ID: E7B75D080FCF7992
3 changed files with 3 additions and 2 deletions

View File

@ -8,6 +8,7 @@ Features:
Bugfixes:
* Parser: disallow empty enum definitions.
* Type checker: disallow conversion between different enum types.
### 0.4.4 (2016-10-31)

View File

@ -1585,7 +1585,7 @@ size_t EnumType::numberOfMembers() const
bool EnumType::isExplicitlyConvertibleTo(Type const& _convertTo) const
{
return _convertTo.category() == category() || _convertTo.category() == Category::Integer;
return _convertTo == *this || _convertTo.category() == Category::Integer;
}
unsigned EnumType::memberValue(ASTString const& _member) const

View File

@ -348,7 +348,7 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp
}
break;
case Type::Category::Enum:
solAssert(targetTypeCategory == Type::Category::Integer || targetTypeCategory == Type::Category::Enum, "");
solAssert(_targetType == _typeOnStack || targetTypeCategory == Type::Category::Integer, "");
break;
case Type::Category::FixedPoint:
solAssert(false, "Not yet implemented - FixedPointType.");