mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow uppercase X in hex number literals
This commit is contained in:
parent
5f919d02ab
commit
b409faa675
@ -41,6 +41,7 @@ Breaking Changes:
|
||||
* Optimizer: Remove the no-op ``PUSH1 0 NOT AND`` sequence.
|
||||
* Parser: Disallow trailing dots that are not followed by a number.
|
||||
* Parser: Remove ``constant`` as function state mutability modifier.
|
||||
* Parser: Disallow uppercase X in hex number literals
|
||||
* Type Checker: Disallow assignments between tuples with different numbers of components. This was already the case in the experimental 0.5.0 mode.
|
||||
* Type Checker: Disallow values for constants that are not compile-time constants. This was already the case in the experimental 0.5.0 mode.
|
||||
* Type Checker: Disallow arithmetic operations for boolean variables.
|
||||
|
@ -132,7 +132,7 @@ HexLiteral = 'hex' ('"' ([0-9a-fA-F]{2})* '"' | '\'' ([0-9a-fA-F]{2})* '\'')
|
||||
StringLiteral = '"' ([^"\r\n\\] | '\\' .)* '"'
|
||||
Identifier = [a-zA-Z_$] [a-zA-Z_$0-9]*
|
||||
|
||||
HexNumber = '0' [xX] [0-9a-fA-F]+
|
||||
HexNumber = '0x' [0-9a-fA-F]+
|
||||
DecimalNumber = [0-9]+ ( '.' [0-9]* )? ( [eE] [0-9]+ )?
|
||||
|
||||
TupleExpression = '(' ( Expression? ( ',' Expression? )* )? ')'
|
||||
|
@ -780,13 +780,13 @@ Token::Value Scanner::scanNumber(char _charSeen)
|
||||
{
|
||||
addLiteralCharAndAdvance();
|
||||
// either 0, 0exxx, 0Exxx, 0.xxx or a hex number
|
||||
if (m_char == 'x' || m_char == 'X')
|
||||
if (m_char == 'x')
|
||||
{
|
||||
// hex number
|
||||
kind = HEX;
|
||||
addLiteralCharAndAdvance();
|
||||
if (!isHexDigit(m_char))
|
||||
return Token::Illegal; // we must have at least one hex digit after 'x'/'X'
|
||||
return Token::Illegal; // we must have at least one hex digit after 'x'
|
||||
|
||||
while (isHexDigit(m_char) || m_char == '_') // We keep the underscores for later validation
|
||||
addLiteralCharAndAdvance();
|
||||
|
@ -105,6 +105,11 @@ BOOST_AUTO_TEST_CASE(hex_numbers)
|
||||
BOOST_CHECK_EQUAL(scanner.currentLiteral(), "0x765432536763762734623472346");
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Semicolon);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
|
||||
scanner.reset(CharStream("0x1234"), "");
|
||||
BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number);
|
||||
BOOST_CHECK_EQUAL(scanner.currentLiteral(), "0x1234");
|
||||
scanner.reset(CharStream("0X1234"), "");
|
||||
BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Illegal);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(octal_numbers)
|
||||
|
Loading…
Reference in New Issue
Block a user