Skip to content

Commit c0311de

Browse files
vezenovmAztecBot
authored andcommitted
fix(aztec-nr): Use mutable ref when mutating variable in closure (#12311)
Post noir-lang/noir#7488 aztec-nr is going to fail to compile as we now explicitly error when attempting to use a capture mutably (lambda captures are meant to be entirely immutable). The current code only worked because it was done at comptime.
1 parent ba10b27 commit c0311de

File tree

1 file changed

+4
-3
lines changed
  • aztec/src/macros/dispatch

1 file changed

+4
-3
lines changed

aztec/src/macros/dispatch/mod.nr

+4-3
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ pub comptime fn generate_public_dispatch(m: Module) -> Quoted {
3636
}
3737
};
3838

39-
let mut parameter_index = 0;
39+
let parameter_index = &mut 0;
4040
let reads = parameters.map(|param: (Quoted, Type)| {
41-
let param_name = f"arg{parameter_index}".quoted_contents();
41+
let parameter_index_value = *parameter_index;
42+
let param_name = f"arg{parameter_index_value}".quoted_contents();
4243
let param_type = param.1;
4344
let read = quote {
4445
let $param_name: $param_type = reader.read_struct(dep::aztec::protocol_types::traits::Deserialize::deserialize);
4546
};
46-
parameter_index += 1;
47+
*parameter_index += 1;
4748
quote { $read }
4849
});
4950
let read = reads.join(quote { });

0 commit comments

Comments
 (0)