diff --git a/compiler/noirc_frontend/src/tests/traits.rs b/compiler/noirc_frontend/src/tests/traits.rs index d2f9d9a9672..51056a1c749 100644 --- a/compiler/noirc_frontend/src/tests/traits.rs +++ b/compiler/noirc_frontend/src/tests/traits.rs @@ -1245,3 +1245,51 @@ fn as_trait_path_in_expression() { "#; assert_no_errors(src); } + +// TODO: remove `should_panic` once fixed +#[test] +#[should_panic = "Expected no errors"] +fn allows_renaming_trait_during_import() { + // Regression test for https://github.com/noir-lang/noir/issues/7632 + let src = r#" + mod trait_mod { + pub trait Foo { + fn foo(_: Self) {} + } + + impl Foo for Field {} + } + + use trait_mod::Foo as FooTrait; + + fn main(x: Field) { + x.foo(); + } + "#; + assert_no_errors(src); +} + +// TODO: remove `should_panic` once fixed +#[test] +#[should_panic = "Expected no errors"] +fn renaming_trait_avoids_name_collisions() { + // Regression test for https://github.com/noir-lang/noir/issues/7632 + let src = r#" + mod trait_mod { + pub trait Foo { + fn foo(_: Self) {} + } + + impl Foo for Field {} + } + + use trait_mod::Foo as FooTrait; + + pub struct Foo {} + + fn main(x: Field) { + x.foo(); + } + "#; + assert_no_errors(src); +}