Skip to content

Commit

Permalink
Test leaking private type via public function arg
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh committed Oct 17, 2024
1 parent ead94ae commit 018777c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion compiler/noirc_frontend/src/tests/visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand All @@ -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#"
Expand Down

0 comments on commit 018777c

Please sign in to comment.