Skip to content

Commit

Permalink
Improve error reporting of trailing commas
Browse files Browse the repository at this point in the history
  • Loading branch information
federicobond committed Jun 15, 2017
1 parent 54e97d1 commit 60bfae7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions libsolidity/parsing/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,13 +1335,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);
Expand Down

0 comments on commit 60bfae7

Please sign in to comment.