From 4a326bff7e7dafc4dbf36c2c4441047d155ac383 Mon Sep 17 00:00:00 2001 From: cozis Date: Mon, 15 Aug 2022 16:38:16 +0200 Subject: [PATCH] bugfix! Missing error check in argument parsing routine --- examples/func.noja | 9 +++++++++ src/lib/compiler/parse.c | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 examples/func.noja diff --git a/examples/func.noja b/examples/func.noja new file mode 100644 index 0000000..3f3c6b2 --- /dev/null +++ b/examples/func.noja @@ -0,0 +1,9 @@ + +fun add(a: int | float = 1, b = 8) + return a + b; + +c = add(3, 4); + +assert(c == 7); + +print(c); \ No newline at end of file diff --git a/src/lib/compiler/parse.c b/src/lib/compiler/parse.c index 797c457..f13d13b 100644 --- a/src/lib/compiler/parse.c +++ b/src/lib/compiler/parse.c @@ -2023,7 +2023,9 @@ static Node *parse_function_definition(Context *ctx) int argc = 0; // Initialization for the warning. Node *argv = parse_function_arguments(ctx, &argc); - + if(argv == NULL) + return NULL; + if(done(ctx)) { Error_Report(ctx->error, 0, "Source ended before function body");