mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Allow constant variables in pure functions.
This commit is contained in:
parent
15bdc48a73
commit
b756274357
@ -179,7 +179,7 @@ void ViewPureChecker::endVisit(Identifier const& _identifier)
|
||||
bool writes = _identifier.annotation().lValueRequested;
|
||||
if (VariableDeclaration const* varDecl = dynamic_cast<VariableDeclaration const*>(declaration))
|
||||
{
|
||||
if (varDecl->isStateVariable())
|
||||
if (varDecl->isStateVariable() && !varDecl->isConstant())
|
||||
mutability = writes ? StateMutability::NonPayable : StateMutability::View;
|
||||
}
|
||||
else if (MagicVariableDeclaration const* magicVar = dynamic_cast<MagicVariableDeclaration const*>(declaration))
|
||||
|
@ -378,6 +378,19 @@ BOOST_AUTO_TEST_CASE(assembly_jump)
|
||||
CHECK_WARNING(text, "low-level EVM features");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(constant)
|
||||
{
|
||||
string text = R"(
|
||||
contract C {
|
||||
uint constant x = 2;
|
||||
function k() pure returns (uint) {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user