@@ -101,6 +101,41 @@ bool replace_symbolt::replace(exprt &dest) const
101
101
if (!replace_symbol_expr (to_symbol_expr (dest)))
102
102
return false ;
103
103
}
104
+ else if (dest.id () == ID_let)
105
+ {
106
+ auto &let_expr = to_let_expr (dest);
107
+
108
+ // first replace the assigned value expressions
109
+ for (auto &op : let_expr.values ())
110
+ if (replace (op))
111
+ result = false ;
112
+
113
+ // now set up the binding
114
+ auto old_bindings = bindings;
115
+ for (auto &variable : let_expr.variables ())
116
+ bindings.insert (variable.get_identifier ());
117
+
118
+ // now replace in the 'where' expression
119
+ if (!replace (let_expr.where ()))
120
+ result = false ;
121
+
122
+ bindings = std::move (old_bindings);
123
+ }
124
+ else if (
125
+ dest.id () == ID_array_comprehension || dest.id () == ID_exists ||
126
+ dest.id () == ID_forall || dest.id () == ID_lambda)
127
+ {
128
+ auto &binding_expr = to_binding_expr (dest);
129
+
130
+ auto old_bindings = bindings;
131
+ for (auto &binding : binding_expr.variables ())
132
+ bindings.insert (binding.get_identifier ());
133
+
134
+ if (!replace (binding_expr.where ()))
135
+ result = false ;
136
+
137
+ bindings = std::move (old_bindings);
138
+ }
104
139
else
105
140
{
106
141
Forall_operands (it, dest)
@@ -136,7 +171,10 @@ bool replace_symbolt::have_to_replace(const exprt &dest) const
136
171
if (dest.id ()==ID_symbol)
137
172
{
138
173
const irep_idt &identifier = to_symbol_expr (dest).get_identifier ();
139
- return replaces_symbol (identifier);
174
+ if (bindings.find (identifier) != bindings.end ())
175
+ return false ;
176
+ else
177
+ return replaces_symbol (identifier);
140
178
}
141
179
142
180
forall_operands (it, dest)
0 commit comments