Fix#4743: Incorrect source location for nameless parameters

This commit is contained in:
bakaoh 2018-08-28 11:11:40 +07:00
parent 410d288dfc
commit c458f5988b

View File

@ -572,6 +572,7 @@ ASTPointer<VariableDeclaration> Parser::parseVariableDeclaration(
Token::Value token = m_scanner->currentToken(); Token::Value token = m_scanner->currentToken();
if (_options.isStateVariable && Token::isVariableVisibilitySpecifier(token)) if (_options.isStateVariable && Token::isVariableVisibilitySpecifier(token))
{ {
nodeFactory.markEndPosition();
if (visibility != Declaration::Visibility::Default) if (visibility != Declaration::Visibility::Default)
{ {
parserError(string( parserError(string(
@ -616,21 +617,21 @@ ASTPointer<VariableDeclaration> Parser::parseVariableDeclaration(
} }
else else
break; break;
nodeFactory.markEndPosition();
m_scanner->next(); m_scanner->next();
} }
} }
nodeFactory.markEndPosition();
if (_options.allowEmptyName && m_scanner->currentToken() != Token::Identifier) if (_options.allowEmptyName && m_scanner->currentToken() != Token::Identifier)
{ {
identifier = make_shared<ASTString>(""); identifier = make_shared<ASTString>("");
solAssert(!_options.allowVar, ""); // allowEmptyName && allowVar makes no sense solAssert(!_options.allowVar, ""); // allowEmptyName && allowVar makes no sense
if (type)
nodeFactory.setEndPositionFromNode(type);
// if type is null this has already caused an error
} }
else else
{
nodeFactory.markEndPosition();
identifier = expectIdentifierToken(); identifier = expectIdentifierToken();
}
ASTPointer<Expression> value; ASTPointer<Expression> value;
if (_options.allowInitialValue) if (_options.allowInitialValue)
{ {