diff --git a/kclvm/sema/src/advanced_resolver/node.rs b/kclvm/sema/src/advanced_resolver/node.rs index 19284cde6..d7f085c11 100644 --- a/kclvm/sema/src/advanced_resolver/node.rs +++ b/kclvm/sema/src/advanced_resolver/node.rs @@ -1007,10 +1007,36 @@ impl<'ctx> AdvancedResolver<'ctx> { if maybe_def { let (start_pos, end_pos): Range = first_name.get_span_pos(); let ast_id = first_name.id.clone(); - let first_value = self.gs.get_symbols_mut().alloc_value_symbol( - ValueSymbol::new(first_name.node.clone(), start_pos, end_pos, None, false), - self.ctx.get_node_key(&ast_id), - ); + + let ty = self + .ctx + .node_ty_map + .get(&self.ctx.get_node_key(&first_name.id)); + let first_value = match ty { + Some(ty) if matches!(ty.kind, TypeKind::Function(_)) => { + self.gs.get_symbols_mut().alloc_function_symbol( + FunctionSymbol::new( + first_name.node.clone(), + start_pos, + end_pos, + None, + false, + ), + self.ctx.get_node_key(&ast_id), + ) + } + _ => self.gs.get_symbols_mut().alloc_value_symbol( + ValueSymbol::new( + first_name.node.clone(), + start_pos, + end_pos, + None, + false, + ), + self.ctx.get_node_key(&ast_id), + ), + }; + self.gs.get_scopes_mut().add_def_to_scope( cur_scope, first_name.node.clone(), diff --git a/kclvm/tools/src/LSP/src/semantic_token.rs b/kclvm/tools/src/LSP/src/semantic_token.rs index b87acf16d..c8fa82614 100644 --- a/kclvm/tools/src/LSP/src/semantic_token.rs +++ b/kclvm/tools/src/LSP/src/semantic_token.rs @@ -155,7 +155,7 @@ mod tests { (1, 4, 4, 2), // name (2, 0, 1, 0), // n (0, 3, 3, 4), // num - (2, 0, 4, 0), // func + (2, 0, 4, 8), // func (0, 14, 1, 0), // x (1, 4, 1, 0), // x ];