mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9405 from ethereum/remove-constant-keyword
[BREAKING] Removed specialized errors for constant state mutability for functions
This commit is contained in:
commit
308af23615
@ -305,10 +305,9 @@ namespace TokenTraits
|
||||
constexpr bool isVisibilitySpecifier(Token op) { return isVariableVisibilitySpecifier(op) || op == Token::External; }
|
||||
constexpr bool isLocationSpecifier(Token op) { return op == Token::Memory || op == Token::Storage || op == Token::CallData; }
|
||||
|
||||
constexpr bool isStateMutabilitySpecifier(Token op, bool _allowConstant = true)
|
||||
constexpr bool isStateMutabilitySpecifier(Token op)
|
||||
{
|
||||
return (op == Token::Constant && _allowConstant)
|
||||
|| op == Token::Pure || op == Token::View || op == Token::Payable;
|
||||
return op == Token::Pure || op == Token::View || op == Token::Payable;
|
||||
}
|
||||
|
||||
constexpr bool isEtherSubdenomination(Token op) { return op >= Token::SubWei && op <= Token::SubEther; }
|
||||
|
@ -464,14 +464,6 @@ StateMutability Parser::parseStateMutability()
|
||||
case Token::Pure:
|
||||
stateMutability = StateMutability::Pure;
|
||||
break;
|
||||
case Token::Constant:
|
||||
stateMutability = StateMutability::View;
|
||||
parserError(
|
||||
7698_error,
|
||||
"The state mutability modifier \"constant\" was removed in version 0.5.0. "
|
||||
"Use \"view\" or \"pure\" instead."
|
||||
);
|
||||
break;
|
||||
default:
|
||||
solAssert(false, "Invalid state mutability specifier.");
|
||||
}
|
||||
@ -997,7 +989,7 @@ ASTPointer<TypeName> Parser::parseTypeName(bool _allowVar)
|
||||
auto stateMutability = elemTypeName.token() == Token::Address
|
||||
? optional<StateMutability>{StateMutability::NonPayable}
|
||||
: nullopt;
|
||||
if (TokenTraits::isStateMutabilitySpecifier(m_scanner->currentToken(), false))
|
||||
if (TokenTraits::isStateMutabilitySpecifier(m_scanner->currentToken()))
|
||||
{
|
||||
if (elemTypeName.token() == Token::Address)
|
||||
{
|
||||
@ -2065,7 +2057,7 @@ Parser::LookAheadInfo Parser::peekStatementType() const
|
||||
// kind of statement. This means, for example, that we do not allow type expressions of the form
|
||||
// ``address payable;``.
|
||||
// If we want to change this in the future, we need to consider another scanner token here.
|
||||
if (TokenTraits::isElementaryTypeName(token) && TokenTraits::isStateMutabilitySpecifier(next, false))
|
||||
if (TokenTraits::isElementaryTypeName(token) && TokenTraits::isStateMutabilitySpecifier(next))
|
||||
return LookAheadInfo::VariableDeclaration;
|
||||
if (next == Token::Identifier || TokenTraits::isLocationSpecifier(next))
|
||||
return LookAheadInfo::VariableDeclaration;
|
||||
|
@ -5,4 +5,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// ParserError 7698: (43-51): The state mutability modifier "constant" was removed in version 0.5.0. Use "view" or "pure" instead.
|
||||
// ParserError 2314: (43-51): Expected '{' but got 'constant'
|
||||
|
@ -17,10 +17,7 @@ contract c6 {
|
||||
function f() pure payable {}
|
||||
}
|
||||
contract c7 {
|
||||
function f() pure constant {}
|
||||
}
|
||||
contract c8 {
|
||||
function f() view constant {}
|
||||
function f() view payable {}
|
||||
}
|
||||
// ----
|
||||
// ParserError 9680: (39-46): State mutability already specified as "payable".
|
||||
@ -29,5 +26,4 @@ contract c8 {
|
||||
// ParserError 9680: (180-184): State mutability already specified as "pure".
|
||||
// ParserError 9680: (229-233): State mutability already specified as "payable".
|
||||
// ParserError 9680: (275-282): State mutability already specified as "pure".
|
||||
// ParserError 9680: (324-332): State mutability already specified as "pure".
|
||||
// ParserError 9680: (374-382): State mutability already specified as "view".
|
||||
// ParserError 9680: (324-331): State mutability already specified as "view".
|
||||
|
Loading…
Reference in New Issue
Block a user