diff --git a/crates/noirc_frontend/src/hir/resolution/resolver.rs b/crates/noirc_frontend/src/hir/resolution/resolver.rs index 0c10936f633..48771db8821 100644 --- a/crates/noirc_frontend/src/hir/resolution/resolver.rs +++ b/crates/noirc_frontend/src/hir/resolution/resolver.rs @@ -1726,6 +1726,7 @@ mod test { } } + #[test] fn resolve_basic_closure() { let src = r#" fn main(x : Field) -> pub Field { @@ -1740,6 +1741,29 @@ mod test { } } + #[test] + fn resolve_simplified_closure() { + // based on bug https://github.com/noir-lang/noir/issues/1088 + + let src = r#"fn do_closure(x: Field) -> Field { + let y = x; + let ret_capture = || { + y + }; + ret_capture() + } + + fn main(x: Field) { + assert(do_closure(x) == 100); + } + + "#; + let parsed_captures = get_program_captures(src); + let mut expected_captures = vec![]; + expected_captures.push(vec!["y".to_string()]); + assert_eq!(expected_captures, parsed_captures); + } + #[test] fn resolve_complex_closures() { let src = r#"