aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2017-03-02 02:49:15 +0800
committerchriseth <c@ethdev.com>2017-03-13 20:30:23 +0800
commit14948e514d7b15eb92d2c08f018bb23ead71fa5a (patch)
treeb1a1e3c3f3d65b1254ccfd5d073f393fab84c7c9
parent49cfacced291ea73d99ec1353a0c77bfe476729a (diff)
downloaddexon-solidity-14948e514d7b15eb92d2c08f018bb23ead71fa5a.tar.gz
dexon-solidity-14948e514d7b15eb92d2c08f018bb23ead71fa5a.tar.zst
dexon-solidity-14948e514d7b15eb92d2c08f018bb23ead71fa5a.zip
Allow enum values for constants.
-rw-r--r--libsolidity/analysis/TypeChecker.cpp5
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp1
2 files changed, 4 insertions, 2 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 38da9b14..75530739 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1466,7 +1466,10 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
}
// TODO some members might be pure, but for example `address(0x123).balance` is not pure
- // although every subexpression is, so leaving this to false for now.
+ // although every subexpression is, so leaving this limited for now.
+ if (auto tt = dynamic_cast<TypeType const*>(exprType.get()))
+ if (tt->actualType()->category() == Type::Category::Enum)
+ annotation.isPure = true;
return false;
}
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index f14108ca..552352e4 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -4542,7 +4542,6 @@ BOOST_AUTO_TEST_CASE(simple_constant_variables_test)
BOOST_AUTO_TEST_CASE(constant_variables)
{
- //for now constant specifier is valid only for uint, bytesXX, string and enums
char const* sourceCode = R"(
contract Foo {
uint constant x = 56;