aboutsummaryrefslogtreecommitdiff
path: root/src/compile/cli.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-10-12 14:19:59 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-10-12 14:19:59 -0400
commit6e5fb2ac4e5b780c74f310446ddd80d571170b0d (patch)
tree587241a69065c01b890d7ae70a37af08bba646b1 /src/compile/cli.c
parent3cd3b20f58e9d2c6463d503be09e5d4cfaadee6c (diff)
More code cleanups
Diffstat (limited to 'src/compile/cli.c')
-rw-r--r--src/compile/cli.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/compile/cli.c b/src/compile/cli.c
index f138bd78..4138b778 100644
--- a/src/compile/cli.c
+++ b/src/compile/cli.c
@@ -88,9 +88,13 @@ Text_t compile_cli_arg_call(env_t *env, Text_t fn_name, type_t *fn_type, const c
for (arg_t *arg = fn_info->args; arg; arg = arg->next) {
code = Texts(code, compile_declaration(arg->type, Texts("_$", Text$from_str(arg->name))));
if (arg->default_val) {
- Text_t default_val =
- arg->type ? compile_to_type(env, arg->default_val, arg->type) : compile(env, arg->default_val);
- if (arg->type->tag != OptionalType) default_val = promote_to_optional(arg->type, default_val);
+ Text_t default_val;
+ if (arg->type) {
+ default_val = compile_to_type(env, arg->default_val, arg->type);
+ if (arg->type->tag != OptionalType) default_val = promote_to_optional(arg->type, default_val);
+ } else {
+ default_val = compile(env, arg->default_val);
+ }
code = Texts(code, " = ", default_val);
} else {
code = Texts(code, " = ", compile_empty(arg->type));