Skip to content

Commit

Permalink
chore: add regression tests for #6314
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljklein committed Oct 28, 2024
1 parent 4c39514 commit dcb40d1
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions compiler/noirc_frontend/src/tests/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,57 @@ fn errors_if_impl_trait_constraint_is_not_satisfied() {
assert_eq!(typ, "SomeGreeter");
assert_eq!(impl_trait, "Foo");
}

#[test]
fn regression_6314_single() {
let src = r#"
trait Foo {
fn foo(self) -> Self;
}
trait Baz: Foo {}
impl<T> Baz for T where T: Foo {}
fn main() { }
"#;
assert_no_errors(src);
}

#[test]
fn regression_6314_double() {
let src = r#"
trait Foo {
fn foo(self) -> Self;
}
trait Bar {
fn bar(self) -> Self;
}
trait Baz: Foo + Bar {}
impl<T> Baz for T where T: Foo + Bar {}
fn baz<T>(x: T) -> T where T: Baz {
x.foo().bar()
}
impl Foo for Field {
fn foo(self) -> Self {
self + 1
}
}
impl Bar for Field {
fn bar(self) -> Self {
self + 2
}
}
fn main() {
assert(0.foo().bar() == baz(0));
}
"#;
assert_no_errors(src);
}

0 comments on commit dcb40d1

Please sign in to comment.