Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add regression tests for #6314 #6381

Merged
merged 6 commits into from
Oct 30, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions compiler/noirc_frontend/src/tests/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,56 @@ fn errors_if_impl_trait_constraint_is_not_satisfied() {
}

#[test]
fn regression_6314_single() {
TomAFrench marked this conversation as resolved.
Show resolved Hide resolved
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));
}
TomAFrench marked this conversation as resolved.
Show resolved Hide resolved

fn removes_assumed_parent_traits_after_function_ends() {
let src = r#"
trait Foo {}
Expand Down
Loading