From 26bc5a796abe08810cb310ea4b7b4b1129e5ce3d Mon Sep 17 00:00:00 2001 From: servostar Date: Thu, 10 Oct 2024 23:27:40 +0200 Subject: [PATCH] fix: mangle function name only when parent module is available --- src/set/set.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/set/set.c b/src/set/set.c index 2fbfe6a..9698157 100644 --- a/src/set/set.c +++ b/src/set/set.c @@ -2698,13 +2698,15 @@ int createFunction(Function* function, AST_NODE_PTR currentNode) { // compose function name by appending parent modules char* modules = module_ref_to_str(currentNode->location.module_ref); - char* composed_name = - g_strjoin("", modules, "::", function->name, NULL); - char* cached_composed_name = - mem_strdup(MemoryNamespaceSet, composed_name); + if (strlen(modules) > 0) { + char* composed_name = + g_strjoin("", modules, "::", function->name, NULL); + char* cached_composed_name = + mem_strdup(MemoryNamespaceSet, composed_name); - g_free(composed_name); - function->name = cached_composed_name; + g_free(composed_name); + function->name = cached_composed_name; + } } mem_free(functionParameter);