Fix bug in constant evaluator.

This commit is contained in:
chriseth 2020-12-09 11:31:25 +01:00
parent fca8026250
commit 251f2a4d93
3 changed files with 10 additions and 1 deletions

View File

@ -271,7 +271,8 @@ optional<TypedRational> ConstantEvaluator::evaluate(ASTNode const& _node)
if (auto const* varDecl = dynamic_cast<VariableDeclaration const*>(&_node))
{
solAssert(varDecl->isConstant(), "");
if (!varDecl->value())
// In some circumstances, we do not yet have a type for the variable.
if (!varDecl->value() || !varDecl->type())
m_values[&_node] = nullopt;
else
{

View File

@ -0,0 +1,3 @@
int[L] constant L = 6;
// ----
// TypeError 5462: (4-5): Invalid array length, expected integer literal or constant expression.

View File

@ -0,0 +1,5 @@
contract C {
int[L] constant L = 6;
}
// ----
// TypeError 5462: (21-22): Invalid array length, expected integer literal or constant expression.