From 60bfae75e51c4f5213c82d17d32e10d939ebf0bf Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Thu, 15 Jun 2017 13:10:08 -0300 Subject: Improve error reporting of trailing commas --- libsolidity/parsing/Parser.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 7c439211..a49f60e2 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -1335,13 +1335,19 @@ pair>, vector>> 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); -- cgit