mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #3775 from federicobond/improve-error-fractional-shift
Improve error message when attempting to shift by fractional number
This commit is contained in:
commit
3bb54e8bd5
@ -12,6 +12,7 @@ Bugfixes:
|
||||
* Commandline interface: Support ``--evm-version constantinople`` properly.
|
||||
* DocString Parser: Fix error message for empty descriptions.
|
||||
* Standard JSON: Support ``constantinople`` as ``evmVersion`` properly.
|
||||
* Type System: Improve error message when attempting to shift by a fractional amount.
|
||||
* Type System: Make external library functions accessible.
|
||||
|
||||
### 0.4.21 (2018-03-07)
|
||||
|
@ -327,7 +327,7 @@ bool isValidShiftAndAmountType(Token::Value _operator, Type const& _shiftAmountT
|
||||
else if (IntegerType const* otherInt = dynamic_cast<decltype(otherInt)>(&_shiftAmountType))
|
||||
return !otherInt->isAddress();
|
||||
else if (RationalNumberType const* otherRat = dynamic_cast<decltype(otherRat)>(&_shiftAmountType))
|
||||
return otherRat->integerType() && !otherRat->integerType()->isSigned();
|
||||
return !otherRat->isFractional() && otherRat->integerType() && !otherRat->integerType()->isSigned();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
@ -5643,6 +5643,16 @@ BOOST_AUTO_TEST_CASE(shift_constant_right_excessive_rvalue)
|
||||
CHECK_ERROR(text, TypeError, "Operator >> not compatible with types int_const 66 and int_const 4294967296");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(shift_constant_right_fractional)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract C {
|
||||
uint public a = 0x42 >> (1 / 2);
|
||||
}
|
||||
)";
|
||||
CHECK_ERROR(text, TypeError, "Operator >> not compatible with types int_const 66 and rational_const 1 / 2");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_positive_stack)
|
||||
{
|
||||
char const* text = R"(
|
||||
|
Loading…
Reference in New Issue
Block a user