Merge pull request #3628 from ethereum/literalsHexUnit

Deprecate using unit denominations in combination with hex numbers.
This commit is contained in:
chriseth
2018-03-02 11:11:16 +01:00
committed by GitHub
3 changed files with 37 additions and 0 deletions
+17
View File
@@ -2021,6 +2021,8 @@ void TypeChecker::endVisit(ElementaryTypeNameExpression const& _expr)
void TypeChecker::endVisit(Literal const& _literal)
{
bool const v050 = m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050);
if (_literal.looksLikeAddress())
{
if (_literal.passesAddressChecksum())
@@ -2034,6 +2036,21 @@ void TypeChecker::endVisit(Literal const& _literal)
"For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals"
);
}
if (_literal.isHexNumber() && _literal.subDenomination() != Literal::SubDenomination::None)
{
if (v050)
m_errorReporter.fatalTypeError(
_literal.location(),
"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.annotation().type)
_literal.annotation().type = Type::forLiteral(_literal);