mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10224 from ethereum/strict-literal-to-enum-conversion
[BREAKING] Strict explicit conversion between literals and enums
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user