From f78212546312192b741dd429b57786132d5187bb Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Wed, 27 Feb 2019 11:55:59 +0100 Subject: [PATCH] Fix SMT Checker crash due to missing type information --- libsolidity/analysis/TypeChecker.cpp | 3 +++ libsolidity/formal/SMTChecker.cpp | 1 + test/libsolidity/smtCheckerTests/simple/static_array.sol | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 86514cf01..6c63af96f 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -448,6 +448,9 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) ) m_errorReporter.typeError(_variable.location(), "Variables cannot be declared in interfaces."); + if (_variable.typeName()) + _variable.typeName()->accept(*this); + // type is filled either by ReferencesResolver directly from the type name or by // TypeChecker at the VariableDeclarationStatement level. TypePointer varType = _variable.annotation().type; diff --git a/libsolidity/formal/SMTChecker.cpp b/libsolidity/formal/SMTChecker.cpp index 234eba106..1f6e85356 100644 --- a/libsolidity/formal/SMTChecker.cpp +++ b/libsolidity/formal/SMTChecker.cpp @@ -695,6 +695,7 @@ void SMTChecker::visitFunctionIdentifier(Identifier const& _identifier) void SMTChecker::endVisit(Literal const& _literal) { + solAssert(_literal.annotation().type, "Expected type for AST node"); Type const& type = *_literal.annotation().type; if (isNumber(type.category())) diff --git a/test/libsolidity/smtCheckerTests/simple/static_array.sol b/test/libsolidity/smtCheckerTests/simple/static_array.sol index 394ace74e..be49ab7fe 100644 --- a/test/libsolidity/smtCheckerTests/simple/static_array.sol +++ b/test/libsolidity/smtCheckerTests/simple/static_array.sol @@ -3,6 +3,10 @@ contract C { // Used to crash because Literal had no type int[3] d; + // Used to crash because Literal had no type + int[3*1] x; } // ---- // Warning: (92-100): Assertion checker does not yet support the type of this variable. +// Warning: (149-159): Assertion checker does not yet support the type of this variable. +// Warning: (153-156): Assertion checker does not yet implement this operator on non-integer types.