From 27d9689e2f6ff5ccfedb8a56e58bffbaf4e9a310 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 17 Aug 2025 16:23:30 -0400 Subject: Don't allow compiling optional values into non-optional ones. --- src/typecheck.c | 2 ++ 1 file changed, 2 insertions(+) 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); } -- cgit v1.2.3