Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

fix(julia): recognize short-form 'f(x) = body' (assignment with call LHS) as a function

Martin Vogel5bb745b9f749
diff --git a/internal/cbm/extract_defs.c b/internal/cbm/extract_defs.c
index f26c36506..51dec0ba9 100644
--- a/internal/cbm/extract_defs.c
+++ b/internal/cbm/extract_defs.c
@@ -316,6 +316,18 @@ static TSNode resolve_func_name_scripting(TSNode node, CBMLanguage lang, const c
if (lang == CBM_LANG_JULIA && strcmp(kind, "function_definition") == 0) {
return resolve_julia_func_name(node);
}
+ /* Julia short-form `name(args) = body` parses as an `assignment` whose LHS is
+ * a call_expression (`name(args)`); the function name is that call's head
+ * identifier. A plain `x = 5` (non-call LHS) is not a function — resolve NULL
+ * so it is neither extracted as a def nor scoped. */
+ if (lang == CBM_LANG_JULIA && strcmp(kind, "assignment") == 0) {
+ if (ts_node_named_child_count(node) > 0) {
+ TSNode lhs = ts_node_named_child(node, 0);
+ if (!ts_node_is_null(lhs) && strcmp(ts_node_type(lhs), "call_expression") == 0) {
+ return resolve_julia_func_name(lhs);
+ }
+ }
+ }
TSNode null_node = {0};
return null_node;
diff --git a/internal/cbm/lang_specs.c b/internal/cbm/lang_specs.c
index 88f72aeb7..e7c97fcc0 100644
--- a/internal/cbm/lang_specs.c
+++ b/internal/cbm/lang_specs.c
@@ -722,7 +722,11 @@ static const char *fsharp_branch_types[] = {"if_expression", "for_expression"
static const char *fsharp_var_types[] = {"value_declaration", NULL};
// ==================== JULIA ====================
-static const char *julia_func_types[] = {"function_definition", "short_function_definition", NULL};
+/* `assignment` covers Julia short-form `f(x) = body` (the grammar parses it as an
+ * assignment with a call_expression LHS, not a short_function_definition). The
+ * resolver names it only when the LHS is a call, so plain `x = 5` is not a def. */
+static const char *julia_func_types[] = {"function_definition", "short_function_definition",
+ "assignment", NULL};
static const char *julia_class_types[] = {"struct_definition", "abstract_definition",
"primitive_definition", NULL};
static const char *julia_module_types[] = {"source_file", NULL};