Merge pull request #2409 from federicobond/trailing-commas-2

Improve error reporting of trailing commas
This commit is contained in:
chriseth 2017-06-19 12:01:19 +02:00 committed by GitHub
commit 622703c0c0

View File

@ -1350,13 +1350,19 @@ pair<vector<ASTPointer<Expression>>, vector<ASTPointer<ASTString>>> Parser::pars
if (!first)
expectToken(Token::Comma);
if (m_scanner->currentToken() == Token::RBrace)
fatalParserError("Unexpected trailing comma.");
ret.second.push_back(expectIdentifierToken());
expectToken(Token::Colon);
ret.first.push_back(parseExpression());
if (
m_scanner->currentToken() == Token::Comma &&
m_scanner->peekNextToken() == Token::RBrace
)
{
parserError("Unexpected trailing comma.");
m_scanner->next();
}
first = false;
}
expectToken(Token::RBrace);