mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Allow constant integer variables as array lengths.
This commit is contained in:
committed by
Alex Beregszaszi
parent
5c9e273d02
commit
165857b1d4
@@ -74,3 +74,21 @@ void ConstantEvaluator::endVisit(Literal const& _literal)
|
||||
if (!_literal.annotation().type)
|
||||
m_errorReporter.fatalTypeError(_literal.location(), "Invalid literal value.");
|
||||
}
|
||||
|
||||
void ConstantEvaluator::endVisit(Identifier const& _identifier)
|
||||
{
|
||||
VariableDeclaration const *variableDeclaration = dynamic_cast<VariableDeclaration const *>(_identifier.annotation().referencedDeclaration);
|
||||
if (!variableDeclaration)
|
||||
return;
|
||||
if (!variableDeclaration->isConstant())
|
||||
m_errorReporter.fatalTypeError(_identifier.location(), "Identifier must be declared constant.");
|
||||
|
||||
ASTPointer<Expression> value = variableDeclaration->value();
|
||||
if (value)
|
||||
{
|
||||
if (!value->annotation().type)
|
||||
ConstantEvaluator e(*value, m_errorReporter);
|
||||
|
||||
_identifier.annotation().type = value->annotation().type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ private:
|
||||
virtual void endVisit(BinaryOperation const& _operation);
|
||||
virtual void endVisit(UnaryOperation const& _operation);
|
||||
virtual void endVisit(Literal const& _literal);
|
||||
virtual void endVisit(Identifier const& _identifier);
|
||||
|
||||
ErrorReporter& m_errorReporter;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user