diff --git a/crates/hir/src/analysis/name_resolution/path_resolver.rs b/crates/hir/src/analysis/name_resolution/path_resolver.rs index 1a905395fe..31e13136a5 100644 --- a/crates/hir/src/analysis/name_resolution/path_resolver.rs +++ b/crates/hir/src/analysis/name_resolution/path_resolver.rs @@ -1285,7 +1285,18 @@ pub fn resolve_name_res<'db>( path, }) } - ScopeId::FuncParam(item, idx) => PathRes::FuncParam(item, idx), + ScopeId::FuncParam(item, idx) => { + if !args.is_empty() { + return Err(PathResError::new( + PathResErrorKind::ArgNumMismatch { + expected: 0, + given: args.len(), + }, + path, + )); + } + PathRes::FuncParam(item, idx) + } ScopeId::Field(..) => unreachable!(), ScopeId::Block(..) => unreachable!(), }, diff --git a/crates/hir/src/analysis/ty/ty_check/expr.rs b/crates/hir/src/analysis/ty/ty_check/expr.rs index 86757b9c2d..5db4e5409d 100644 --- a/crates/hir/src/analysis/ty/ty_check/expr.rs +++ b/crates/hir/src/analysis/ty/ty_check/expr.rs @@ -771,7 +771,17 @@ impl<'db> TyChecker<'db> { ExprProp::invalid(self.db) } } - PathRes::Mod(_) | PathRes::FuncParam(..) => todo!(), + PathRes::Mod(scope) => { + let diag = BodyDiag::NotValue { + primary: path_expr_span.clone().into(), + given: Either::Left(scope.item()), + }; + self.push_diag(diag); + ExprProp::invalid(self.db) + } + PathRes::FuncParam(..) => { + unreachable!("func params should be resolved as bindings") + } }, } } diff --git a/crates/uitest/fixtures/ty_check/not_value_mod_and_func_param.fe b/crates/uitest/fixtures/ty_check/not_value_mod_and_func_param.fe new file mode 100644 index 0000000000..c6ce8c8105 --- /dev/null +++ b/crates/uitest/fixtures/ty_check/not_value_mod_and_func_param.fe @@ -0,0 +1,6 @@ +mod m {} + +fn test(x: i32) { + m + x +} diff --git a/crates/uitest/fixtures/ty_check/not_value_mod_and_func_param.snap b/crates/uitest/fixtures/ty_check/not_value_mod_and_func_param.snap new file mode 100644 index 0000000000..70142c70c8 --- /dev/null +++ b/crates/uitest/fixtures/ty_check/not_value_mod_and_func_param.snap @@ -0,0 +1,16 @@ +--- +source: crates/uitest/tests/ty_check.rs +expression: diags +input_file: fixtures/ty_check/not_value_mod_and_func_param.fe +--- +error[2-0011]: incorrect number of generic arguments for `x`; expected 0, given 1 + ┌─ not_value_mod_and_func_param.fe:5:5 + │ +5 │ x + │ ^ expected 0 arguments, but 1 were given + +error[8-0030]: value is expected + ┌─ not_value_mod_and_func_param.fe:4:5 + │ +4 │ m + │ ^ `mod` cannot be used as a value