From 0233a1ad06379b60a6ff7a38eaea65ff469422ee Mon Sep 17 00:00:00 2001 From: Alexander Ivanov Date: Mon, 31 Jul 2023 14:35:27 +0300 Subject: [PATCH] test: add simplification of #1088 as a resolve test, enable another test --- .../src/hir/resolution/resolver.rs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/crates/noirc_frontend/src/hir/resolution/resolver.rs b/crates/noirc_frontend/src/hir/resolution/resolver.rs index 12525cb3ba8..dae01eee8f4 100644 --- a/crates/noirc_frontend/src/hir/resolution/resolver.rs +++ b/crates/noirc_frontend/src/hir/resolution/resolver.rs @@ -1815,6 +1815,7 @@ mod test { } } + #[test] fn resolve_basic_closure() { let src = r#" fn main(x : Field) -> pub Field { @@ -1829,6 +1830,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#"