aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2017-03-04 02:26:54 +0800
committerchriseth <c@ethdev.com>2017-03-13 20:30:23 +0800
commit592cec7e9074313e7ce5539769c065ecf5cbba12 (patch)
tree72a26e95183f4356f68e9ae5c02756062a58415d /libsolidity
parent4077e56a2fad49227e7fe4c1ed4ff81462fc6a9a (diff)
downloaddexon-solidity-592cec7e9074313e7ce5539769c065ecf5cbba12.tar
dexon-solidity-592cec7e9074313e7ce5539769c065ecf5cbba12.tar.gz
dexon-solidity-592cec7e9074313e7ce5539769c065ecf5cbba12.tar.bz2
dexon-solidity-592cec7e9074313e7ce5539769c065ecf5cbba12.tar.lz
dexon-solidity-592cec7e9074313e7ce5539769c065ecf5cbba12.tar.xz
dexon-solidity-592cec7e9074313e7ce5539769c065ecf5cbba12.tar.zst
dexon-solidity-592cec7e9074313e7ce5539769c065ecf5cbba12.zip
Disallow constants that are neither value types nor strings.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 75530739..41636db7 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -473,6 +473,14 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
{
if (!_variable.isStateVariable())
typeError(_variable.location(), "Illegal use of \"constant\" specifier.");
+ if (!_variable.type()->isValueType())
+ {
+ bool allowed = false;
+ if (auto arrayType = dynamic_cast<ArrayType const*>(_variable.type().get()))
+ allowed = arrayType->isString();
+ if (!allowed)
+ typeError(_variable.location(), "Constants of non-value type not yet implemented.");
+ }
if (!_variable.value())
typeError(_variable.location(), "Uninitialized \"constant\" variable.");
else if (!_variable.value()->annotation().isPure)