Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,13 @@ impl<'a> ModCollector<'a> {
for trait_impl in impls {
let trait_name = trait_impl.trait_name.clone();

let unresolved_functions =
let mut unresolved_functions =
self.collect_trait_impl_function_overrides(context, &trait_impl, krate);

let module = ModuleId { krate, local_id: self.module_id };

for (_, func_id, noir_function) in &unresolved_functions.functions {
for (_, func_id, noir_function) in &mut unresolved_functions.functions {
noir_function.def.where_clause.append(&mut trait_impl.where_clause.clone());
context.def_interner.push_function(*func_id, &noir_function.def, module);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "impl_with_where_clause"
type = "bin"
authors = [""]
compiler_version = "0.10.5"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

fn main() {
let array: [Field; 3] = [1, 2, 3];
assert(array.eq(array));

// Ensure this still works if we have to infer the type of the integer literals
let array = [1, 2, 3];
assert(array.eq(array));
}

trait Eq {
fn eq(self, other: Self) -> bool;
}

impl<T, N> Eq for [T; N] where T: Eq {
fn eq(self, other: Self) -> bool {
let mut ret = true;
for i in 0 .. self.len() {
ret &= self[i].eq(other[i]);
}
ret
}
}

impl Eq for Field {
fn eq(self, other: Field) -> bool {
self == other
}
}