Merge pull request #10542 from ethereum/fixConstantEv

Fix bug in constant evaluator.
This commit is contained in:
Alex Beregszaszi
2020-12-09 16:04:42 +00:00
committed by GitHub
3 changed files with 10 additions and 1 deletions
+2 -1
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
{
@@ -0,0 +1,3 @@
int[L] constant L = 6;
// ----
// TypeError 5462: (4-5): Invalid array length, expected integer literal or constant expression.
@@ -0,0 +1,5 @@
contract C {
int[L] constant L = 6;
}
// ----
// TypeError 5462: (21-22): Invalid array length, expected integer literal or constant expression.