From 592cec7e9074313e7ce5539769c065ecf5cbba12 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 3 Mar 2017 19:26:54 +0100 Subject: Disallow constants that are neither value types nor strings. --- libsolidity/analysis/TypeChecker.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libsolidity') 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(_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) -- cgit v1.2.3