diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-04-20 15:00:31 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-04-20 15:00:31 -0400 |
| commit | a4ffdb1798b7ce037e58fdc50af5b0bf2427d9de (patch) | |
| tree | 79878e35d6edcf65100033046f1af278da54e91e | |
| parent | 2dd9392ef91b953ad5741fa8a955cfd7694a2e05 (diff) | |
Fix no-argument main funcs
| -rw-r--r-- | compile.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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; |
