Merge pull request #9965 from ethereum/var_is_reserved

Var is reserved keyword.
This commit is contained in:
chriseth 2020-10-06 15:49:53 +02:00 committed by GitHub
commit 046cc42121
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -318,7 +318,7 @@ namespace TokenTraits
constexpr bool isEtherSubdenomination(Token op) { return op >= Token::SubWei && op <= Token::SubEther; } constexpr bool isEtherSubdenomination(Token op) { return op >= Token::SubWei && op <= Token::SubEther; }
constexpr bool isTimeSubdenomination(Token op) { return op == Token::SubSecond || op == Token::SubMinute || op == Token::SubHour || op == Token::SubDay || op == Token::SubWeek || op == Token::SubYear; } constexpr bool isTimeSubdenomination(Token op) { return op == Token::SubSecond || op == Token::SubMinute || op == Token::SubHour || op == Token::SubDay || op == Token::SubWeek || op == Token::SubYear; }
constexpr bool isReservedKeyword(Token op) { return (Token::After <= op && op <= Token::Unchecked); } constexpr bool isReservedKeyword(Token op) { return (Token::After <= op && op <= Token::Var); }
constexpr bool isYulKeyword(Token tok) constexpr bool isYulKeyword(Token tok)
{ {

View File

@ -121,6 +121,7 @@ BOOST_AUTO_TEST_CASE(reserved_keywords)
BOOST_CHECK(!TokenTraits::isReservedKeyword(Token::Identifier)); BOOST_CHECK(!TokenTraits::isReservedKeyword(Token::Identifier));
BOOST_CHECK(TokenTraits::isReservedKeyword(Token::After)); BOOST_CHECK(TokenTraits::isReservedKeyword(Token::After));
BOOST_CHECK(TokenTraits::isReservedKeyword(Token::Unchecked)); BOOST_CHECK(TokenTraits::isReservedKeyword(Token::Unchecked));
BOOST_CHECK(TokenTraits::isReservedKeyword(Token::Var));
BOOST_CHECK(!TokenTraits::isReservedKeyword(Token::Illegal)); BOOST_CHECK(!TokenTraits::isReservedKeyword(Token::Illegal));
} }
@ -514,10 +515,11 @@ BOOST_AUTO_TEST_CASE(keyword_is_reserved)
"switch", "switch",
"typedef", "typedef",
"typeof", "typeof",
"unchecked" "unchecked",
"var"
}; };
BOOST_CHECK_EQUAL(std::size(keywords), static_cast<int>(Token::Unchecked) - static_cast<int>(Token::After) + 1); BOOST_CHECK_EQUAL(std::size(keywords), static_cast<int>(Token::Var) - static_cast<int>(Token::After) + 1);
for (auto const& keyword: keywords) for (auto const& keyword: keywords)
{ {