From 31b7cab2bf8da6b914f24939e61435a338ba4b0f Mon Sep 17 00:00:00 2001 From: cozis Date: Tue, 2 Nov 2021 16:41:56 +0000 Subject: [PATCH] bug fix --- samples/func.noja | 19 +++++++------------ samples/gang.noja | 4 ++-- src/objects/o_map.c | 2 +- src/runtime/runtime.c | 2 +- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/samples/func.noja b/samples/func.noja index f0d6e0f..dc58017 100644 --- a/samples/func.noja +++ b/samples/func.noja @@ -1,15 +1,10 @@ -fun k(k) - return k(k); - -k(k); - fun x(a, b, c) - print(a, b, c); + print('a = ', a, '\nb = ', b, '\nc = ', c, '\n\n'); -print(x(1, 2, 3)); - -fun hello() - print('hel\nlo', 2); - -return hello(); \ No newline at end of file +x(1, 2, 3, 4, 5); +x(1, 2, 3, 4); +x(1, 2, 3); +x(1, 2); # Fails here! +x(1); +x(); \ No newline at end of file diff --git a/samples/gang.noja b/samples/gang.noja index f710f37..c71b917 100644 --- a/samples/gang.noja +++ b/samples/gang.noja @@ -1,8 +1,8 @@ stack = {count: 0, head: none}; -fun push(stack, value) { - +fun push(stack, value) +{ node = {prev: null, item: value}; node.prev = list.head; diff --git a/src/objects/o_map.c b/src/objects/o_map.c index 6e67721..f6db6ca 100644 --- a/src/objects/o_map.c +++ b/src/objects/o_map.c @@ -52,7 +52,7 @@ Object *Object_NewMap(int num, Heap *heap, Error *error) obj->mapper_size = mapper_size; obj->count = 0; - obj->mapper = Heap_RawMalloc(heap, sizeof(int) * capacity, error); + obj->mapper = Heap_RawMalloc(heap, sizeof(int) * mapper_size, error); obj->keys = Heap_RawMalloc(heap, sizeof(Object*) * capacity, error); obj->vals = Heap_RawMalloc(heap, sizeof(Object*) * capacity, error); diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index 9d1973b..6bb0075 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -546,7 +546,7 @@ static _Bool step(Runtime *runtime, Error *error) { // Variable not defined locally. - if(runtime->builtins) + if(runtime->builtins != NULL) obj = Object_Select(runtime->builtins, key, runtime->heap, error); if(obj == NULL)