aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-04-20 15:00:31 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-04-20 15:00:31 -0400
commita4ffdb1798b7ce037e58fdc50af5b0bf2427d9de (patch)
tree79878e35d6edcf65100033046f1af278da54e91e /compile.c
parent2dd9392ef91b953ad5741fa8a955cfd7694a2e05 (diff)
Fix no-argument main funcs
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c8
1 files 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;