Skip to content

Commit 36e579c

Browse files
Handle nil case in string_refinementt::get
If the underlying solver does not know about the existence of an array, it can return nil, which shouldn't be returned inside an index_expression as in particular the type will be broken.
1 parent 1899067 commit 36e579c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/solvers/strings/string_refinement.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,6 +2060,12 @@ exprt string_refinementt::get(const exprt &expr) const
20602060
}
20612061
const auto array = supert::get(current.get());
20622062
const auto index = get(index_expr->index());
2063+
2064+
// If the underlying solver does not know about the existence of an array,
2065+
// it can return nil, which cannot be used in the expression returned here.
2066+
if(array.is_nil())
2067+
return index_exprt(current, index);
2068+
20632069
const exprt unknown =
20642070
from_integer(CHARACTER_FOR_UNKNOWN, index_expr->type());
20652071
if(
@@ -2070,12 +2076,9 @@ exprt string_refinementt::get(const exprt &expr) const
20702076
return sparse_array->to_if_expression(index);
20712077
}
20722078

2073-
INVARIANT(
2074-
array.is_nil() || array.id() == ID_symbol ||
2075-
array.id() == ID_nondet_symbol,
2076-
std::string("apart from symbols, array valuations can be interpreted as "
2077-
"sparse arrays, id: ") +
2078-
id2string(array.id()));
2079+
INVARIANT(array.id() == ID_symbol || array.id() == ID_nondet_symbol,
2080+
"Apart from symbols, array valuations can be interpreted as "
2081+
"sparse arrays. Array model : " + array.pretty());
20792082
return index_exprt(array, index);
20802083
}
20812084

0 commit comments

Comments
 (0)