mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix parser for function type disambiguity.
This commit is contained in:
parent
0335ed4cb4
commit
7a292c9a05
@ -315,7 +315,18 @@ Parser::FunctionHeaderParserResult Parser::parseFunctionHeader(bool _forceEmptyN
|
||||
m_scanner->next();
|
||||
}
|
||||
else if (_allowModifiers && token == Token::Identifier)
|
||||
{
|
||||
// This can either be a modifier (function declaration) or the name of the
|
||||
// variable (function type name plus variable).
|
||||
if (
|
||||
m_scanner->peekNextToken() == Token::Semicolon ||
|
||||
m_scanner->peekNextToken() == Token::Assign
|
||||
)
|
||||
// Variable declaration, break here.
|
||||
break;
|
||||
else
|
||||
result.modifiers.push_back(parseModifierInvocation());
|
||||
}
|
||||
else if (Token::isVisibilitySpecifier(token))
|
||||
{
|
||||
if (result.visibility != Declaration::Visibility::Default)
|
||||
|
@ -1338,6 +1338,17 @@ BOOST_AUTO_TEST_CASE(mapping_and_array_of_functions)
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(function_type_state_variable)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
function() x;
|
||||
function() y = x;
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user