mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Enforce error on hex number combined with unit denomination
This commit is contained in:
parent
694754b4fe
commit
c1b67a845b
@ -25,6 +25,7 @@ Breaking Changes:
|
|||||||
``sizeof``, ``supports``, ``typedef`` and ``unchecked``.
|
``sizeof``, ``supports``, ``typedef`` and ``unchecked``.
|
||||||
* General: Remove assembly instruction aliases ``sha3`` and ``suicide``
|
* General: Remove assembly instruction aliases ``sha3`` and ``suicide``
|
||||||
* General: C99-style scoping rules are enforced now. This was already the case in the experimental 0.5.0 mode.
|
* General: C99-style scoping rules are enforced now. This was already the case in the experimental 0.5.0 mode.
|
||||||
|
* General: Disallow combining hex numbers with unit denominations (e.g. 0x1e wei). This was already the case in the experimental 0.5.0 mode.
|
||||||
* Optimizer: Remove the no-op ``PUSH1 0 NOT AND`` sequence.
|
* Optimizer: Remove the no-op ``PUSH1 0 NOT AND`` sequence.
|
||||||
* Parser: Disallow trailing dots that are not followed by a number.
|
* Parser: Disallow trailing dots that are not followed by a number.
|
||||||
* Parser: Remove ``constant`` as function state mutability modifer.
|
* Parser: Remove ``constant`` as function state mutability modifer.
|
||||||
|
@ -2267,11 +2267,9 @@ void TypeChecker::endVisit(ElementaryTypeNameExpression const& _expr)
|
|||||||
|
|
||||||
void TypeChecker::endVisit(Literal const& _literal)
|
void TypeChecker::endVisit(Literal const& _literal)
|
||||||
{
|
{
|
||||||
bool const v050 = m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050);
|
|
||||||
|
|
||||||
if (_literal.looksLikeAddress())
|
if (_literal.looksLikeAddress())
|
||||||
{
|
{
|
||||||
// Assign type here if it even looks like an address. This prevents double error in 050 mode for invalid address
|
// Assign type here if it even looks like an address. This prevents double errors for invalid addresses
|
||||||
_literal.annotation().type = make_shared<IntegerType>(160, IntegerType::Modifier::Address);
|
_literal.annotation().type = make_shared<IntegerType>(160, IntegerType::Modifier::Address);
|
||||||
|
|
||||||
string msg;
|
string msg;
|
||||||
@ -2298,20 +2296,11 @@ void TypeChecker::endVisit(Literal const& _literal)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_literal.isHexNumber() && _literal.subDenomination() != Literal::SubDenomination::None)
|
if (_literal.isHexNumber() && _literal.subDenomination() != Literal::SubDenomination::None)
|
||||||
{
|
m_errorReporter.fatalTypeError(
|
||||||
if (v050)
|
_literal.location(),
|
||||||
m_errorReporter.fatalTypeError(
|
"Hexadecimal numbers cannot be used with unit denominations. "
|
||||||
_literal.location(),
|
"You can use an expression of the form \"0x1234 * 1 day\" instead."
|
||||||
"Hexadecimal numbers cannot be used with unit denominations. "
|
);
|
||||||
"You can use an expression of the form \"0x1234 * 1 day\" instead."
|
|
||||||
);
|
|
||||||
else
|
|
||||||
m_errorReporter.warning(
|
|
||||||
_literal.location(),
|
|
||||||
"Hexadecimal numbers with unit denominations are deprecated. "
|
|
||||||
"You can use an expression of the form \"0x1234 * 1 day\" instead."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_literal.subDenomination() == Literal::SubDenomination::Year)
|
if (_literal.subDenomination() == Literal::SubDenomination::Year)
|
||||||
m_errorReporter.typeError(
|
m_errorReporter.typeError(
|
||||||
|
@ -2,4 +2,4 @@ contract C {
|
|||||||
uint constant x = 0x01 wei;
|
uint constant x = 0x01 wei;
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (32-40): Hexadecimal numbers with unit denominations are deprecated. You can use an expression of the form "0x1234 * 1 day" instead.
|
// TypeError: (32-40): Hexadecimal numbers cannot be used with unit denominations. You can use an expression of the form "0x1234 * 1 day" instead.
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
pragma experimental "v0.5.0";
|
|
||||||
contract C {
|
|
||||||
uint constant x = 0x01 wei;
|
|
||||||
}
|
|
||||||
// ----
|
|
||||||
// TypeError: (62-70): Hexadecimal numbers cannot be used with unit denominations. You can use an expression of the form "0x1234 * 1 day" instead.
|
|
Loading…
Reference in New Issue
Block a user