mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Display error if payable or constant is specified multiple times
This commit is contained in:
parent
e0b9589e5a
commit
d170ceaf3d
@ -323,11 +323,17 @@ Parser::FunctionHeaderParserResult Parser::parseFunctionHeader(bool _forceEmptyN
|
|||||||
Token::Value token = m_scanner->currentToken();
|
Token::Value token = m_scanner->currentToken();
|
||||||
if (token == Token::Const)
|
if (token == Token::Const)
|
||||||
{
|
{
|
||||||
|
if (result.isDeclaredConst)
|
||||||
|
parserError(string("Multiple \"constant\" specifiers."));
|
||||||
|
|
||||||
result.isDeclaredConst = true;
|
result.isDeclaredConst = true;
|
||||||
m_scanner->next();
|
m_scanner->next();
|
||||||
}
|
}
|
||||||
else if (m_scanner->currentToken() == Token::Payable)
|
else if (m_scanner->currentToken() == Token::Payable)
|
||||||
{
|
{
|
||||||
|
if (result.isPayable)
|
||||||
|
parserError(string("Multiple \"payable\" specifiers."));
|
||||||
|
|
||||||
result.isPayable = true;
|
result.isPayable = true;
|
||||||
m_scanner->next();
|
m_scanner->next();
|
||||||
}
|
}
|
||||||
|
@ -901,6 +901,24 @@ BOOST_AUTO_TEST_CASE(multiple_visibility_specifiers)
|
|||||||
CHECK_PARSE_ERROR(text, "Visibility already specified");
|
CHECK_PARSE_ERROR(text, "Visibility already specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(multiple_payable_specifiers)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract c {
|
||||||
|
function f() payable payable {}
|
||||||
|
})";
|
||||||
|
CHECK_PARSE_ERROR(text, "Multiple \"payable\" specifiers.");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(multiple_constant_specifiers)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract c {
|
||||||
|
function f() constant constant {}
|
||||||
|
})";
|
||||||
|
CHECK_PARSE_ERROR(text, "Multiple \"constant\" specifiers.");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations)
|
BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
|
Loading…
Reference in New Issue
Block a user