You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change mutable variables given in environment to lambda.
Mutable variable is created and then given as environment to lambda function. Lambda function changes this variable's value.
Expected Behavior
Mutable variables change their values outside of lambda function when they are in this function's environment.
fnmain(){letmut x = 3;let f = || {
x += 2;};f();assert(x == 5);}
The issue is that we allow x += 2; at all within the lambda since captures are meant to be immutable.
To capture mutable variables a mutable reference must be used:
fnmain(){let x = &mut3;let f = || {*x += 2;};f();assert(*x == 5);}
Aim
Change mutable variables given in environment to lambda.
Mutable variable is created and then given as environment to lambda function. Lambda function changes this variable's value.
Expected Behavior
Mutable variables change their values outside of lambda function when they are in this function's environment.
Bug
Variables don't change their value.
To Reproduce
nargo execute
Project Impact
Nice-to-have
Impact Context
No response
Workaround
None
Workaround Description
No response
Additional Context
No response
Installation Method
Binary (
noirup
default)Nargo Version
nargo version = 0.26.0 noirc version = 0.26.0+c46b164ce56e6a8f81255fb17eb6539bd040f336
NoirJS Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: