Skip to content

Commit

Permalink
chore: add test for missing lambda closure environment (#2120) (#4212)
Browse files Browse the repository at this point in the history
# Description

This issue has been resolved, presumably by
github.com//pull/2457, but this test no longer appears to
be in the repo so re-adding it to prevent regressions.

## Problem\*

Resolves #2120 

## Summary\*

This just adds a test.

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
michaeljklein authored Feb 1, 2024
1 parent 96a74bb commit 4467ea9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "missing_closure_env"
type = "bin"
authors = [""]
compiler_version = ">=0.23.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = 42
16 changes: 16 additions & 0 deletions test_programs/execution_success/missing_closure_env/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
fn main(x: Field) {
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);
assert(x == 42);
}

#[test]
fn test_main() {
main(42);
}

0 comments on commit 4467ea9

Please sign in to comment.