Adds support for arrays in function signatures.

This commit is contained in:
Erik Kundt 2019-03-06 16:47:00 +01:00
parent 9193fcb99f
commit ab31c28ed9
3 changed files with 30 additions and 1 deletions

View File

@ -11,7 +11,7 @@ Bugfixes:
Build System:
* Soltest: Add support for arrays in function signatures.
### 0.5.5 (2019-03-05)

View File

@ -252,6 +252,15 @@ string TestFileParser::parseIdentifierOrTuple()
{
identOrTuple = m_scanner.currentLiteral();
expect(Token::Identifier);
while (accept(Token::LBrack))
{
identOrTuple += formatToken(Token::LBrack);
expect(Token::LBrack);
if (accept(Token::Number))
identOrTuple += parseDecimalNumber();
identOrTuple += formatToken(Token::RBrack);
expect(Token::RBrack);
}
return identOrTuple;
}
expect(Token::LParen);
@ -402,6 +411,12 @@ void TestFileParser::Scanner::scanNextToken()
case ')':
token = selectToken(Token::RParen);
break;
case '[':
token = selectToken(Token::LBrack);
break;
case ']':
token = selectToken(Token::RBrack);
break;
default:
if (langutil::isIdentifierStart(current()))
{

View File

@ -460,6 +460,20 @@ BOOST_AUTO_TEST_CASE(call_multiple_arguments_mixed_format)
);
}
BOOST_AUTO_TEST_CASE(call_signature_array)
{
char const* source = R"(
// f(uint256[]) ->
// f(uint256[3]) ->
// f(uint256[3][][], uint8[9]) ->
)";
auto const calls = parse(source);
BOOST_REQUIRE_EQUAL(calls.size(), 3);
testFunctionCall(calls.at(0), Mode::SingleLine, "f(uint256[])", false);
testFunctionCall(calls.at(1), Mode::SingleLine, "f(uint256[3])", false);
testFunctionCall(calls.at(2), Mode::SingleLine, "f(uint256[3][][],uint8[9])", false);
}
BOOST_AUTO_TEST_CASE(call_signature_valid)
{
char const* source = R"(