From b8170c3c011f4ec3415139ee254f075b3a0ea8a3 Mon Sep 17 00:00:00 2001 From: Tim Teichmann Date: Wed, 22 Jul 2026 11:21:37 +0200 Subject: [PATCH] fix: 'builtins' --- builtins.c | 13 +++++++++---- lisp.c | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/builtins.c b/builtins.c index e990671..f70887e 100644 --- a/builtins.c +++ b/builtins.c @@ -143,12 +143,17 @@ int lisp_function_builtins(Nodes args, Scopes *scopes, Node *result) { } Scope *global_scope = nob_da_first(scopes); - Nodes nodes = {0}; - nob_da_foreach(ScopeObject, scope_object, global_scope) { - nob_da_append(&nodes, scope_object->node); + Nodes *nodes = malloc(sizeof(Nodes)); + if (nodes == NULL) { + printf("Failed to allocated memory, something is very wrong!\n"); + return 1; } - *result->as_list = nodes; + nob_da_foreach(ScopeObject, scope_object, global_scope) { + nob_da_append(nodes, scope_object->node); + } + + result->as_list = nodes; result->kind = NODE_KIND_LIST; return 0; } diff --git a/lisp.c b/lisp.c index d8b89e4..2b8f4ea 100644 --- a/lisp.c +++ b/lisp.c @@ -53,6 +53,7 @@ void build_scopes(Scopes *scopes) { scope_add_function(&global_scope, "append", lisp_function_append); scope_add_function(&global_scope, "length", lisp_function_length); scope_add_function(&global_scope, "null?", lisp_function_isnull); + scope_add_function(&global_scope, "builtins", lisp_function_builtins); scope_add_function(&global_scope, "floor", lisp_function_floor); scope_add_function(&global_scope, "ceil", lisp_function_ceil);