diff options
author | Federico Bond <federicobond@gmail.com> | 2017-06-14 11:09:11 +0800 |
---|---|---|
committer | Federico Bond <federicobond@gmail.com> | 2017-06-14 11:15:27 +0800 |
commit | fd8365df08aafc7ab7cfac5fa916d910343d0eb3 (patch) | |
tree | 9b7e9192a022bc203efe240aed453b4cc18689f6 /libsolidity/parsing | |
parent | c99c1c76f7ce2963b1401b53676ca3bbb0eadbea (diff) | |
download | dexon-solidity-fd8365df08aafc7ab7cfac5fa916d910343d0eb3.tar.gz dexon-solidity-fd8365df08aafc7ab7cfac5fa916d910343d0eb3.tar.zst dexon-solidity-fd8365df08aafc7ab7cfac5fa916d910343d0eb3.zip |
Forbid trailing commas in named arguments
Diffstat (limited to 'libsolidity/parsing')
-rw-r--r-- | libsolidity/parsing/Parser.cpp | 13 |
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); } |