mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow certain implicit conversions between integer types.
Disallow implicit conversion from ``uintN`` and ``intM`` when ``M > N``, and by extension, explicit conversion between the same types are also disallowed.
This commit is contained in:
@@ -508,12 +508,13 @@ BoolResult IntegerType::isImplicitlyConvertibleTo(Type const& _convertTo) const
|
||||
if (_convertTo.category() == category())
|
||||
{
|
||||
IntegerType const& convertTo = dynamic_cast<IntegerType const&>(_convertTo);
|
||||
if (convertTo.m_bits < m_bits)
|
||||
// disallowing unsigned to signed conversion of different bits
|
||||
if (isSigned() != convertTo.isSigned())
|
||||
return false;
|
||||
else if (convertTo.m_bits < m_bits)
|
||||
return false;
|
||||
else if (isSigned())
|
||||
return convertTo.isSigned();
|
||||
else
|
||||
return !convertTo.isSigned() || convertTo.m_bits > m_bits;
|
||||
return true;
|
||||
}
|
||||
else if (_convertTo.category() == Category::FixedPoint)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user