Forbid trailing commas in named arguments

This commit is contained in:
Federico Bond
2017-06-14 00:15:27 -03:00
parent c99c1c76f7
commit fd8365df08
2 changed files with 20 additions and 4 deletions
+9 -4
View File
@@ -1328,16 +1328,21 @@ pair<vector<ASTPointer<Expression>>, vector<ASTPointer<ASTString>>> 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);
}