Skip to content
Draft
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
7 changes: 7 additions & 0 deletions compiler/noirc_frontend/src/elaborator/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1996,6 +1996,13 @@ impl Elaborator<'_> {
expr_location: location,
});
}
Type::Error => {
self.push_err(TypeCheckError::ExpectingOtherError {
message: "type_check_operator_method: encountered method_type of type 'error'"
.to_string(),
location,
});
}
other => {
unreachable!(
"Expected operator method on {object_type} to have a function type, but found {other}"
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/node_interner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ impl NodeInterner {
method_ids,
associated_types: vec![],
associated_type_bounds: Default::default(),
name: Ident::new("Dummy".to_string(), Location::dummy()),
name: Ident::new("PopulateDummyOperatorTraitsTrait".to_string(), Location::dummy()),
generics: vec![],
location: Location::dummy(),
visibility: ItemVisibility::Public,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,3 +715,36 @@ fn regression_10537() {
"#;
check_errors_with_stdlib(src, [stdlib_src::EQ, stdlib_src::ORD]);
}

// Expecting missing `Eq` impl errors to resolve to a `NoMatchingImplFound` error
// with a trait name of "PopulateDummyOperatorTraitsTrait" when the `Eq` trait
// hasn't been explicitly defined, i.e. when it's only been defined by
// `NodeInterner::populate_dummy_operator_traits`
#[test]
fn missing_eq_trait_error() {
let src = "
struct Foo {}
fn main() {
let x = Foo {};
let y = Foo {};
assert(x == y);
^^^^^^ No matching impl found for `Foo: PopulateDummyOperatorTraitsTrait`
~~~~~~ No impl for `Foo: PopulateDummyOperatorTraitsTrait`
}
";
check_errors(src);
}

#[test]
fn regression_10219() {
let src = "
fn main() {
let mut x: u32 = 0;
let mut y: u32 = 0;
assert(&mut x == &mut y);
^^^^^^^^^^^^^^^^ No matching impl found for `&mut u32: Eq`
~~~~~~~~~~~~~~~~ No impl for `&mut u32: Eq`
}
";
check_errors_with_stdlib(src, [stdlib_src::EQ]);
}
Loading