aboutsummaryrefslogtreecommitdiff
path: root/src/typecheck.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-08-17 16:23:30 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-08-17 16:23:30 -0400
commit27d9689e2f6ff5ccfedb8a56e58bffbaf4e9a310 (patch)
treed7ee2fdc04103a52adf6c0cb6d9448b8a7c92fdc /src/typecheck.c
parente1d6add4f36419ca4fd5fee7b9ba6202c9bf8a5a (diff)
Don't allow compiling optional values into non-optional ones.
Diffstat (limited to 'src/typecheck.c')
-rw-r--r--src/typecheck.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/typecheck.c b/src/typecheck.c
index ba30931e..d99048ff 100644
--- a/src/typecheck.c
+++ b/src/typecheck.c
@@ -1829,6 +1829,8 @@ PUREFUNC bool can_compile_to_type(env_t *env, ast_t *ast, type_t *needed)
return ptr->is_stack && can_compile_to_type(env, Match(ast, StackReference)->value, ptr->pointed);
else
return can_promote(actual, needed);
+ } else if (actual->tag == OptionalType && needed->tag != OptionalType) {
+ return false;
} else {
return can_promote(actual, needed);
}