Skip to content

Commit

Permalink
fix: Closure lvalue capture bugfix (#2457)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvitkov authored Aug 28, 2023
1 parent 4609c1a commit 632006a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,17 @@ fn main(mut x: Field) {
add2(&mut x);
assert(x == 3);

issue_2120();
}

// https://github.com/noir-lang/noir/issues/2120
fn issue_2120() {
let x1 = &mut 42;
let set_x1 = |y| { *x1 = y; };

assert(*x1 == 42);
set_x1(44);
assert(*x1 == 44);
set_x1(*x1);
assert(*x1 == 44);
}
2 changes: 1 addition & 1 deletion crates/noirc_frontend/src/monomorphization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ impl<'interner> Monomorphizer<'interner> {
});

let location = None; // TODO: This should match the location of the lambda expression
let mutable = false;
let mutable = true;
let definition = Definition::Local(env_local_id);

let env_ident = ast::Ident {
Expand Down

0 comments on commit 632006a

Please sign in to comment.