mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests for payable / private combination.
This commit is contained in:
parent
ff11aa1927
commit
384f189a6a
@ -423,9 +423,9 @@ bool TypeChecker::visit(FunctionDefinition const& _function)
|
||||
typeError(_function.location(), "Library functions cannot be payable.");
|
||||
if (!_function.isConstructor() && !_function.name().empty() && !_function.isPartOfExternalInterface())
|
||||
typeError(_function.location(), "Internal functions cannot be payable.");
|
||||
if (_function.isDeclaredConst())
|
||||
typeError(_function.location(), "Functions cannot be constant and payable at the same time.");
|
||||
}
|
||||
if (_function.isPayable() && _function.isDeclaredConst())
|
||||
typeError(_function.location(), "Functions cannot be constant and payable at the same time.");
|
||||
for (ASTPointer<VariableDeclaration> const& var: _function.parameters() + _function.returnParameters())
|
||||
{
|
||||
if (!type(*var)->canLiveOutsideStorage())
|
||||
|
@ -3865,6 +3865,16 @@ BOOST_AUTO_TEST_CASE(payable_in_library)
|
||||
BOOST_CHECK(expectError(text) == Error::Type::TypeError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(payable_external)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
function f() payable external {}
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK(success(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(payable_internal)
|
||||
{
|
||||
char const* text = R"(
|
||||
@ -3875,6 +3885,16 @@ BOOST_AUTO_TEST_CASE(payable_internal)
|
||||
BOOST_CHECK(expectError(text) == Error::Type::TypeError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(payable_private)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
function f() payable private {}
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK(expectError(text) == Error::Type::TypeError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(illegal_override_payable)
|
||||
{
|
||||
char const* text = R"(
|
||||
|
Loading…
Reference in New Issue
Block a user