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