-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix an ICE when reassigning a mutable lambda variable to one wit…
…h a different environment type (#2172) * fix: don't allow lambda reassignment if closure types dont match * fix: add test for bad lambda reassignment * fix: cargo fmt & clippy * fix: alternate approach --------- Co-authored-by: Alex Vitkov <[email protected]>
- Loading branch information
1 parent
14cbdbc
commit a56db3e
Showing
2 changed files
with
15 additions
and
2 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
crates/nargo_cli/tests/compile_tests_data/fail/different-lambda-env-reassign-disallow.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
fn bad() { | ||
let a: i32 = 100; | ||
let b: i32 = 200; | ||
|
||
let mut f = || a; | ||
|
||
// this should fail with a type error, since the closures have different environments & types | ||
f = || a + b; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters