Diagnose call expression on non-callable things

This commit is contained in:
Lukas Wirth 2023-03-03 18:04:24 +01:00
parent 3ba876a4a6
commit 3c7a0aa00e
6 changed files with 83 additions and 14 deletions

View file

@ -170,6 +170,7 @@ pub enum InferenceDiagnostic {
// FIXME: Make this proper
BreakOutsideOfLoop { expr: ExprId, is_break: bool, bad_value_break: bool },
MismatchedArgCount { call_expr: ExprId, expected: usize, found: usize },
ExpectedFunction { call_expr: ExprId, found: Ty },
}
/// A mismatch between an expected and an inferred type.
@ -505,6 +506,14 @@ impl<'a> InferenceContext<'a> {
mismatch.expected = table.resolve_completely(mismatch.expected.clone());
mismatch.actual = table.resolve_completely(mismatch.actual.clone());
}
for diagnostic in &mut result.diagnostics {
match diagnostic {
InferenceDiagnostic::ExpectedFunction { found, .. } => {
*found = table.resolve_completely(found.clone())
}
_ => (),
}
}
for (_, subst) in result.method_resolutions.values_mut() {
*subst = table.resolve_completely(subst.clone());
}