Disallow constants that are neither value types nor strings.

This commit is contained in:
chriseth
2017-03-13 13:30:23 +01:00
parent 4077e56a2f
commit 592cec7e90
4 changed files with 55 additions and 26 deletions
+8
View File
@@ -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)