From a4ffdb1798b7ce037e58fdc50af5b0bf2427d9de Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 20 Apr 2024 15:00:31 -0400 Subject: Fix no-argument main funcs --- compile.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compile.c b/compile.c index 000bcaf8..1c54b5e3 100644 --- a/compile.c +++ b/compile.c @@ -1920,8 +1920,12 @@ CORD compile_type_info(env_t *env, type_t *t) CORD compile_cli_arg_call(env_t *env, CORD fn_name, type_t *fn_type) { auto fn_info = Match(fn_type, FunctionType); - if (!fn_info->args) - return "if (argc > 1) errx(1, \"This program doesn't take any arguments.\");\n"; + if (!fn_info->args) { + return CORD_all( + "if (argc > 1)\n" + "errx(1, \"This program doesn't take any arguments.\");\n", + fn_name, "();\n"); + } env_t *main_env = fresh_scope(env); CORD usage = CORD_EMPTY; -- cgit v1.2.3