aboutsummaryrefslogtreecommitdiff
path: root/src/compile/integers.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-10-05 17:52:33 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-10-05 17:52:33 -0400
commit398d2cab6988e20c59e7037ff7ef551540339abb (patch)
tree8c5154cfcd32d0664fd40ac8fa93f50f6434859a /src/compile/integers.c
parent9b5b6b110bb80f8530dd7ca4e0cc9eb3236d8ad7 (diff)
Fix a bunch of issues with optional types
Diffstat (limited to 'src/compile/integers.c')
-rw-r--r--src/compile/integers.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/compile/integers.c b/src/compile/integers.c
index 41c2b78a..78d48b70 100644
--- a/src/compile/integers.c
+++ b/src/compile/integers.c
@@ -22,11 +22,13 @@ Text_t compile_int_to_type(env_t *env, ast_t *ast, type_t *target) {
return code;
}
- if (target->tag == BigIntType) return compile(env, ast);
+ if (non_optional(target)->tag == BigIntType) return compile(env, ast);
- if (target->tag == OptionalType && Match(target, OptionalType)->type)
+ if (target->tag == OptionalType && Match(target, OptionalType)->type) {
return Texts("((", compile_type(target),
- "){.value=", compile_int_to_type(env, ast, Match(target, OptionalType)->type), "})");
+ "){.value=", compile_int_to_type(env, ast, Match(target, OptionalType)->type),
+ ", .has_value=true})");
+ }
const char *literal = Match(ast, Int)->str;
OptionalInt_t int_val = Int$from_str(literal);