From 018777c9edc4163cbd48400a3e10e73d30c6bc22 Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Thu, 17 Oct 2024 18:28:15 +0100 Subject: [PATCH] Test leaking private type via public function arg --- .../noirc_frontend/src/tests/visibility.rs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/compiler/noirc_frontend/src/tests/visibility.rs b/compiler/noirc_frontend/src/tests/visibility.rs index 3740bcff6a..2886420310 100644 --- a/compiler/noirc_frontend/src/tests/visibility.rs +++ b/compiler/noirc_frontend/src/tests/visibility.rs @@ -113,7 +113,7 @@ fn errors_if_pub_struct_field_leaks_private_type_in_generic() { } #[test] -fn errors_if_pub_function_leaks_private_type() { +fn errors_if_pub_function_leaks_private_type_in_return() { let src = r#" pub mod moo { struct Bar {} @@ -129,6 +129,26 @@ fn errors_if_pub_function_leaks_private_type() { assert_type_visibility_error(src, "Bar", "foo"); } +#[test] +fn errors_if_pub_function_leaks_private_type_in_arg() { + let src = r#" + pub mod moo { + struct Bar {} + + pub fn foo(_bar: Bar) { + Bar {} + } + pub fn no_unused_warnings() { + foo(Bar{}); + } + } + fn main() { + moo::no_unused_warnings(); + } + "#; + assert_type_visibility_error(src, "Bar", "foo"); +} + #[test] fn errors_if_trying_to_access_public_function_inside_private_module() { let src = r#"