Merge pull request #10224 from ethereum/strict-literal-to-enum-conversion

[BREAKING] Strict explicit conversion between literals and enums
This commit is contained in:
chriseth
2020-11-10 13:15:12 +01:00
committed by GitHub
7 changed files with 46 additions and 11 deletions
+3
View File
@@ -978,6 +978,9 @@ BoolResult RationalNumberType::isExplicitlyConvertibleTo(Type const& _convertTo)
}
else if (category == Category::Integer)
return false;
else if (auto enumType = dynamic_cast<EnumType const*>(&_convertTo))
if (isNegative() || isFractional() || m_value >= enumType->numberOfMembers())
return false;
TypePointer mobType = mobileType();
return (mobType && mobType->isExplicitlyConvertibleTo(_convertTo));