mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Set header.isConstructor for old style constructors in parseFunctionHeader as well.
This commit is contained in:
parent
f855c78a08
commit
e2dac9ed39
@ -332,14 +332,18 @@ StateMutability Parser::parseStateMutability(Token::Value _token)
|
||||
return stateMutability;
|
||||
}
|
||||
|
||||
Parser::FunctionHeaderParserResult Parser::parseFunctionHeader(bool _forceEmptyName, bool _allowModifiers)
|
||||
Parser::FunctionHeaderParserResult Parser::parseFunctionHeader(
|
||||
bool _forceEmptyName,
|
||||
bool _allowModifiers,
|
||||
ASTString const* _contractName
|
||||
)
|
||||
{
|
||||
RecursionGuard recursionGuard(*this);
|
||||
FunctionHeaderParserResult result;
|
||||
|
||||
if (m_scanner->currentToken() == Token::Function)
|
||||
// In case of old style constructors, i.e. functions with the same name as the contract,
|
||||
// this is set to true later in parseFunctionDefinitionOrFunctionTypeStateVariable.
|
||||
// this is set to true below.
|
||||
result.isConstructor = false;
|
||||
else if (m_scanner->currentToken() == Token::Identifier && m_scanner->currentLiteral() == "constructor")
|
||||
result.isConstructor = true;
|
||||
@ -351,6 +355,10 @@ Parser::FunctionHeaderParserResult Parser::parseFunctionHeader(bool _forceEmptyN
|
||||
result.name = make_shared<ASTString>();
|
||||
else
|
||||
result.name = expectIdentifierToken();
|
||||
|
||||
if (!result.name->empty() && _contractName && *result.name == *_contractName)
|
||||
result.isConstructor = true;
|
||||
|
||||
VarDeclParserOptions options;
|
||||
options.allowLocationSpecifier = true;
|
||||
result.parameters = parseParameterList(options);
|
||||
@ -420,7 +428,7 @@ ASTPointer<ASTNode> Parser::parseFunctionDefinitionOrFunctionTypeStateVariable(A
|
||||
if (m_scanner->currentCommentLiteral() != "")
|
||||
docstring = make_shared<ASTString>(m_scanner->currentCommentLiteral());
|
||||
|
||||
FunctionHeaderParserResult header = parseFunctionHeader(false, true);
|
||||
FunctionHeaderParserResult header = parseFunctionHeader(false, true, _contractName);
|
||||
|
||||
if (
|
||||
!header.modifiers.empty() ||
|
||||
@ -439,8 +447,6 @@ ASTPointer<ASTNode> Parser::parseFunctionDefinitionOrFunctionTypeStateVariable(A
|
||||
}
|
||||
else
|
||||
m_scanner->next(); // just consume the ';'
|
||||
if (_contractName && *header.name == *_contractName)
|
||||
header.isConstructor = true;
|
||||
return nodeFactory.createNode<FunctionDefinition>(
|
||||
header.name,
|
||||
header.visibility,
|
||||
|
@ -74,7 +74,11 @@ private:
|
||||
ASTPointer<InheritanceSpecifier> parseInheritanceSpecifier();
|
||||
Declaration::Visibility parseVisibilitySpecifier(Token::Value _token);
|
||||
StateMutability parseStateMutability(Token::Value _token);
|
||||
FunctionHeaderParserResult parseFunctionHeader(bool _forceEmptyName, bool _allowModifiers);
|
||||
FunctionHeaderParserResult parseFunctionHeader(
|
||||
bool _forceEmptyName,
|
||||
bool _allowModifiers,
|
||||
ASTString const* _contractName = nullptr
|
||||
);
|
||||
ASTPointer<ASTNode> parseFunctionDefinitionOrFunctionTypeStateVariable(ASTString const* _contractName);
|
||||
ASTPointer<FunctionDefinition> parseFunctionDefinition(ASTString const* _contractName);
|
||||
ASTPointer<StructDefinition> parseStructDefinition();
|
||||
|
Loading…
Reference in New Issue
Block a user