Skip to content

Commit

Permalink
chore: add regression test for #6530 (#7089)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljklein authored Jan 16, 2025
1 parent 51180b9 commit c172880
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions compiler/noirc_frontend/src/tests/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,51 @@ fn warns_if_trait_is_not_in_scope_for_generic_function_call_and_there_is_only_on
assert_eq!(trait_name, "private_mod::Foo");
}

// See https://github.com/noir-lang/noir/issues/6530
#[test]
fn regression_6530() {
let src = r#"
pub trait From<T> {
fn from(input: T) -> Self;
}
pub trait Into<T> {
fn into(self) -> T;
}
impl<T, U> Into<T> for U
where
T: From<U>,
{
fn into(self) -> T {
T::from(self)
}
}
struct Foo {
inner: Field,
}
impl Into<Field> for Foo {
fn into(self) -> Field {
self.inner
}
}
fn main() {
let foo = Foo { inner: 0 };
// This works:
let _: Field = Into::<Field>::into(foo);
// This was failing with 'No matching impl':
let _: Field = foo.into();
}
"#;
let errors = get_program_errors(src);
assert_eq!(errors.len(), 0);
}

// See https://github.com/noir-lang/noir/issues/7090
#[test]
#[should_panic]
Expand Down

0 comments on commit c172880

Please sign in to comment.