AsmParser: disallow trailing commas in function call arguments.

This commit is contained in:
Daniel Kirchner 2019-06-06 13:16:27 +02:00
parent e7e700be38
commit 6368cd4c82
5 changed files with 29 additions and 6 deletions

View File

@ -9,6 +9,7 @@ Compiler Features:
Bugfixes:
* Yul / Inline Assembly Parser: Disallow trailing commas in function call arguments.
Build System:

View File

@ -609,12 +609,14 @@ Expression Parser::parseCall(Parser::ElementaryOperation&& _initialOp)
else
ret = std::move(boost::get<FunctionCall>(_initialOp));
expectToken(Token::LParen);
while (currentToken() != Token::RParen)
if (currentToken() != Token::RParen)
{
ret.arguments.emplace_back(parseExpression());
if (currentToken() == Token::RParen)
break;
expectToken(Token::Comma);
while (currentToken() != Token::RParen)
{
expectToken(Token::Comma);
ret.arguments.emplace_back(parseExpression());
}
}
ret.location.end = endPosition();
expectToken(Token::RParen);

View File

@ -3,10 +3,9 @@ contract C {
assembly {
function f(a, b) {}
f()
f(1,)
f(,1)
}
}
}
// ----
// ParserError: (113-114): Literal, identifier or instruction expected.
// ParserError: (101-102): Literal, identifier or instruction expected.

View File

@ -0,0 +1,11 @@
contract C {
function f() public pure {
assembly {
function f(a, b) {}
f()
f(1,)
}
}
}
// ----
// ParserError: (103-104): Literal, identifier or instruction expected.

View File

@ -0,0 +1,10 @@
contract C {
function f() public pure {
assembly {
function f(a, b, c) {}
f(1,,1)
}
}
}
// ----
// ParserError: (96-97): Literal, identifier or instruction expected.