From e3c43633476b167ac7121dff96bbd6360dfc5900 Mon Sep 17 00:00:00 2001 From: Ary Borenszweig Date: Thu, 16 Jan 2025 11:52:11 -0300 Subject: [PATCH] chore: add test for isuee #7090 --- compiler/noirc_frontend/src/tests/traits.rs | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/compiler/noirc_frontend/src/tests/traits.rs b/compiler/noirc_frontend/src/tests/traits.rs index 3a55fc2b67d..30dd994bf2e 100644 --- a/compiler/noirc_frontend/src/tests/traits.rs +++ b/compiler/noirc_frontend/src/tests/traits.rs @@ -1236,3 +1236,30 @@ fn warns_if_trait_is_not_in_scope_for_generic_function_call_and_there_is_only_on assert_eq!(ident.to_string(), "foo"); assert_eq!(trait_name, "private_mod::Foo"); } + +// See https://github.com/noir-lang/noir/issues/7090 +#[test] +#[should_panic] +fn calls_trait_method_using_struct_name_when_multiple_impls_exist() { + let src = r#" + trait From2 { + fn from2(input: T) -> Self; + } + struct U60Repr {} + impl From2<[Field; 3]> for U60Repr { + fn from2(_: [Field; 3]) -> Self { + U60Repr {} + } + } + impl From2 for U60Repr { + fn from2(_: Field) -> Self { + U60Repr {} + } + } + fn main() { + let _ = U60Repr::from2([1, 2, 3]); + let _ = U60Repr::from2(1); + } + "#; + assert_no_errors(src); +}