Merge pull request #7851 from ethereum/smt_fix_function_type

[SMTChecker] Fix ICE for arrays and mappings of functions.
This commit is contained in:
Leonardo
2019-11-30 13:15:08 +01:00
committed by GitHub
7 changed files with 48 additions and 2 deletions
+9 -2
View File
@@ -63,7 +63,7 @@ SortPointer smtSort(solidity::Type const& _type)
{
auto mapType = dynamic_cast<solidity::MappingType const*>(&_type);
solAssert(mapType, "");
return make_shared<ArraySort>(smtSort(*mapType->keyType()), smtSort(*mapType->valueType()));
return make_shared<ArraySort>(smtSortAbstractFunction(*mapType->keyType()), smtSortAbstractFunction(*mapType->valueType()));
}
else if (isStringLiteral(_type.category()))
{
@@ -77,7 +77,7 @@ SortPointer smtSort(solidity::Type const& _type)
solAssert(isArray(_type.category()), "");
auto arrayType = dynamic_cast<solidity::ArrayType const*>(&_type);
solAssert(arrayType, "");
return make_shared<ArraySort>(make_shared<Sort>(Kind::Int), smtSort(*arrayType->baseType()));
return make_shared<ArraySort>(make_shared<Sort>(Kind::Int), smtSortAbstractFunction(*arrayType->baseType()));
}
}
default:
@@ -94,6 +94,13 @@ vector<SortPointer> smtSort(vector<solidity::TypePointer> const& _types)
return sorts;
}
SortPointer smtSortAbstractFunction(solidity::Type const& _type)
{
if (isFunction(_type.category()))
return make_shared<Sort>(Kind::Int);
return smtSort(_type);
}
Kind smtKind(solidity::Type::Category _category)
{
if (isNumber(_category))
+3
View File
@@ -32,6 +32,9 @@ namespace smt
/// Returns the SMT sort that models the Solidity type _type.
SortPointer smtSort(solidity::Type const& _type);
std::vector<SortPointer> smtSort(std::vector<solidity::TypePointer> const& _types);
/// If _type has type Function, abstract it to Integer.
/// Otherwise return smtSort(_type).
SortPointer smtSortAbstractFunction(solidity::Type const& _type);
/// Returns the SMT kind that models the Solidity type type category _category.
Kind smtKind(solidity::Type::Category _category);