Merge pull request #904 from Zokrates/fix-variable-read-remover
Fix variable index write when isolating branches
This commit is contained in:
commit
8dee5ec80b
2 changed files with 3 additions and 1 deletions
1
changelogs/unreleased/904-schaeff
Normal file
1
changelogs/unreleased/904-schaeff
Normal file
|
@ -0,0 +1 @@
|
|||
Fix variable write remover when isolating branches
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue