aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-06-14 21:31:40 +0800
committerGitHub <noreply@github.com>2017-06-14 21:31:40 +0800
commit1ae0e082b316adfc1a048928e5c535559d3780b3 (patch)
treeffa909bd5e932148a3d923149f11738431559c28 /libsolidity
parent0b99c81f8536aa7888f26ac349ab233825350efc (diff)
parentfd8365df08aafc7ab7cfac5fa916d910343d0eb3 (diff)
downloaddexon-solidity-1ae0e082b316adfc1a048928e5c535559d3780b3.tar.gz
dexon-solidity-1ae0e082b316adfc1a048928e5c535559d3780b3.tar.zst
dexon-solidity-1ae0e082b316adfc1a048928e5c535559d3780b3.zip
Merge pull request #2392 from federicobond/disallow-trailing-commas
Forbid trailing commas in named arguments
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/parsing/Parser.cpp13
1 files changed, 9 insertions, 4 deletions
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<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);
}