mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Stricter explicit conversions from Literals to Integers.
Explicit conversions from Literals to Integers will now be as strict as implicit conversions between the same.
This commit is contained in:
parent
5ffee049fa
commit
a555556559
@ -129,10 +129,13 @@ BoolResult fitsIntegerType(bigint const& _value, IntegerType const& _type)
|
||||
/// if _signed is true.
|
||||
bool fitsIntoBits(bigint const& _value, unsigned _bits, bool _signed)
|
||||
{
|
||||
return fitsIntegerType(_value, *TypeProvider::integer(
|
||||
return fitsIntegerType(
|
||||
_value,
|
||||
*TypeProvider::integer(
|
||||
_bits,
|
||||
_signed ? IntegerType::Modifier::Signed : IntegerType::Modifier::Unsigned
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
util::Result<TypePointers> transformParametersToExternal(TypePointers const& _parameters, bool _inLibrary)
|
||||
@ -968,9 +971,13 @@ BoolResult RationalNumberType::isExplicitlyConvertibleTo(Type const& _convertTo)
|
||||
auto category = _convertTo.category();
|
||||
if (category == Category::FixedBytes)
|
||||
return false;
|
||||
if (category == Category::Address)
|
||||
else if (category == Category::Address)
|
||||
{
|
||||
if (isNegative() || isFractional() || integerType()->numBits() > 160)
|
||||
return false;
|
||||
}
|
||||
else if (category == Category::Integer)
|
||||
return false;
|
||||
|
||||
TypePointer mobType = mobileType();
|
||||
return (mobType && mobType->isExplicitlyConvertibleTo(_convertTo));
|
||||
|
Loading…
Reference in New Issue
Block a user