mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Make constant and payable mutually exclusive.
This commit is contained in:
parent
9c64edf110
commit
1eb7ddbb09
@ -424,6 +424,8 @@ bool TypeChecker::visit(FunctionDefinition const& _function)
|
|||||||
if (!_function.isConstructor() && !_function.name().empty() && !_function.isPartOfExternalInterface())
|
if (!_function.isConstructor() && !_function.name().empty() && !_function.isPartOfExternalInterface())
|
||||||
typeError(_function.location(), "Internal functions cannot be payable.");
|
typeError(_function.location(), "Internal functions cannot be payable.");
|
||||||
}
|
}
|
||||||
|
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())
|
for (ASTPointer<VariableDeclaration> const& var: _function.parameters() + _function.returnParameters())
|
||||||
{
|
{
|
||||||
if (!type(*var)->canLiveOutsideStorage())
|
if (!type(*var)->canLiveOutsideStorage())
|
||||||
|
@ -3893,6 +3893,14 @@ BOOST_AUTO_TEST_CASE(illegal_override_payable_nonpayable)
|
|||||||
BOOST_CHECK(expectError(text) == Error::Type::TypeError);
|
BOOST_CHECK(expectError(text) == Error::Type::TypeError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(payable_constant_conflict)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract C { function f() payable constant {} }
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(expectError(text) == Error::Type::TypeError);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(calling_payable)
|
BOOST_AUTO_TEST_CASE(calling_payable)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
|
Loading…
Reference in New Issue
Block a user