From fd8365df08aafc7ab7cfac5fa916d910343d0eb3 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Wed, 14 Jun 2017 00:09:11 -0300 Subject: Forbid trailing commas in named arguments --- libsolidity/parsing/Parser.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'libsolidity') diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index ec27f89b..7c439211 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -1328,16 +1328,21 @@ pair>, vector>> Parser::pars { // call({arg1 : 1, arg2 : 2 }) expectToken(Token::LBrace); + + bool first = true; while (m_scanner->currentToken() != Token::RBrace) { + 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) - expectToken(Token::Comma); - else - break; + first = false; } expectToken(Token::RBrace); } -- cgit v1.2.3