1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00

Merge pull request #904 from Zokrates/fix-variable-read-remover

Fix variable index write when isolating branches
This commit is contained in:
Thibaut Schaeffer 2021-05-31 16:10:17 +02:00 committed by GitHub
commit 8dee5ec80b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -0,0 +1 @@
Fix variable write remover when isolating branches

View file

@ -310,12 +310,13 @@ impl<'ast, T: Field> Folder<'ast, T> for VariableWriteRemover {
fn fold_statement(&mut self, s: TypedStatement<'ast, T>) -> Vec<TypedStatement<'ast, T>> {
match s {
TypedStatement::Definition(assignee, expr) => {
let expr = self.fold_expression(expr);
if is_constant(&assignee) {
vec![TypedStatement::Definition(assignee, expr)]
} else {
// Note: here we redefine the whole object, ideally we would only redefine some of it
// Example: `a[0][i] = 42` we redefine `a` but we could redefine just `a[0]`
let expr = self.fold_expression(expr);
let (variable, indices) = linear(assignee);