[SMTChecker] Fix ICE on array.pop nested inside 1-tuple

This commit is contained in:
Martin Blicha 2021-03-09 20:00:51 +01:00
parent ad5d34df74
commit 4285c2803b
5 changed files with 16 additions and 4 deletions

View File

@ -10,6 +10,7 @@ Compiler Features:
Bugfixes:
* Error Reporter: Fix handling of carriage return.
* SMTChecker: Fix internal error on ``array.pop`` nested inside 1-tuple.
* SMTChecker: Fix internal error on ``FixedBytes`` constant initialized with string literal.
* SMTChecker: Fix internal error on array slices.
* SMTChecker: Fix internal error on calling public getter on a state variable of type array (possibly nested) of structs.

View File

@ -774,7 +774,7 @@ void CHC::makeArrayPopVerificationTarget(FunctionCall const& _arrayPop)
FunctionType const& funType = dynamic_cast<FunctionType const&>(*_arrayPop.expression().annotation().type);
solAssert(funType.kind() == FunctionType::Kind::ArrayPop, "");
auto memberAccess = dynamic_cast<MemberAccess const*>(&_arrayPop.expression());
auto memberAccess = dynamic_cast<MemberAccess const*>(cleanExpression(_arrayPop.expression()));
solAssert(memberAccess, "");
auto symbArray = dynamic_pointer_cast<SymbolicArrayVariable>(m_context.expression(memberAccess->expression()));
solAssert(symbArray, "");

View File

@ -444,6 +444,9 @@ void SMTEncoder::endVisit(Assignment const& _assignment)
void SMTEncoder::endVisit(TupleExpression const& _tuple)
{
if (_tuple.annotation().type->category() == Type::Category::Function)
return;
createExpr(_tuple);
if (_tuple.isInlineArray())
@ -1624,7 +1627,7 @@ void SMTEncoder::arrayPush(FunctionCall const& _funCall)
void SMTEncoder::arrayPop(FunctionCall const& _funCall)
{
auto memberAccess = dynamic_cast<MemberAccess const*>(&_funCall.expression());
auto memberAccess = dynamic_cast<MemberAccess const*>(cleanExpression(_funCall.expression()));
solAssert(memberAccess, "");
auto symbArray = dynamic_pointer_cast<smt::SymbolicArrayVariable>(m_context.expression(memberAccess->expression()));
solAssert(symbArray, "");

View File

@ -19,5 +19,3 @@ contract C {
}
}
// ----
// Warning 6031: (289-292): Internal error: Expression undefined for SMT solver.
// Warning 6031: (289-292): Internal error: Expression undefined for SMT solver.

View File

@ -0,0 +1,10 @@
pragma experimental SMTChecker;
contract C {
int[]data;
function f() public {
(data.pop)();
}
}
// ----
// Warning 2529: (95-107): CHC: Empty array "pop" happens here.\nCounterexample:\ndata = []\n\nTransaction trace:\nC.constructor()\nState: data = []\nC.f()