fix: mangle function name only when parent module is available

This commit is contained in:
Sven Vogel 2024-10-10 23:27:40 +02:00
parent a8bceff951
commit 26bc5a796a
1 changed files with 8 additions and 6 deletions

View File

@ -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);