Skip to content
Open
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
19 changes: 18 additions & 1 deletion src/sema/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,11 @@ pub(super) fn resolve_method_call(
let deref_ty = expr_ty.deref_memory();
let funcs: Vec<_> = BUILTIN_METHODS
.iter()
.filter(|func| func.name == id.name && func.method.contains(deref_ty))
.filter(|func| {
func.name == id.name
&& func.method.contains(deref_ty)
&& (func.target.is_empty() || func.target.contains(&ns.target))
})
.collect();

// try to resolve the arguments, give up if there are any errors
Expand Down Expand Up @@ -1523,6 +1527,19 @@ pub(super) fn resolve_method_call(
}

if funcs.is_empty() {
if BUILTIN_METHODS
.iter()
.any(|func| func.name == id.name && func.method.contains(deref_ty))
{
diagnostics.push(Diagnostic::error(
id.loc,
format!(
"method '{}' is not available on target {}",
id.name, ns.target
),
));
return Err(());
}
Ok(None)
} else {
diagnostics.extend(call_diagnostics);
Expand Down
Loading