From 5afb858e00dd9e1ec2ad82d48f29aae68343a874 Mon Sep 17 00:00:00 2001 From: Micah Date: Mon, 8 Dec 2025 09:04:21 -0300 Subject: [PATCH 1/2] expr type checking for PathRes::Mod and PathRes::FuncParam --- crates/hir/src/analysis/ty/ty_check/expr.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/hir/src/analysis/ty/ty_check/expr.rs b/crates/hir/src/analysis/ty/ty_check/expr.rs index 86757b9c2d..dd4b5306ca 100644 --- a/crates/hir/src/analysis/ty/ty_check/expr.rs +++ b/crates/hir/src/analysis/ty/ty_check/expr.rs @@ -771,7 +771,22 @@ 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(item, _) => { + let diag = BodyDiag::NotValue { + primary: path_expr_span.clone().into(), + given: Either::Left(item), + }; + self.push_diag(diag); + ExprProp::invalid(self.db) + } }, } } From 46f1ee03d30fa5c91071634d18c8c9ac678f79c2 Mon Sep 17 00:00:00 2001 From: Sean Billig Date: Thu, 1 Jan 2026 00:50:00 -0600 Subject: [PATCH 2/2] emit diag for funcparam expr with generic args --- .../analysis/name_resolution/path_resolver.rs | 13 ++++++++++++- crates/hir/src/analysis/ty/ty_check/expr.rs | 9 ++------- .../ty_check/not_value_mod_and_func_param.fe | 6 ++++++ .../ty_check/not_value_mod_and_func_param.snap | 16 ++++++++++++++++ 4 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 crates/uitest/fixtures/ty_check/not_value_mod_and_func_param.fe create mode 100644 crates/uitest/fixtures/ty_check/not_value_mod_and_func_param.snap 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 dd4b5306ca..5db4e5409d 100644 --- a/crates/hir/src/analysis/ty/ty_check/expr.rs +++ b/crates/hir/src/analysis/ty/ty_check/expr.rs @@ -779,13 +779,8 @@ impl<'db> TyChecker<'db> { self.push_diag(diag); ExprProp::invalid(self.db) } - PathRes::FuncParam(item, _) => { - let diag = BodyDiag::NotValue { - primary: path_expr_span.clone().into(), - given: Either::Left(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