aboutsummaryrefslogtreecommitdiff
path: root/typecheck.c
diff options
context:
space:
mode:
Diffstat (limited to 'typecheck.c')
-rw-r--r--typecheck.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/typecheck.c b/typecheck.c
index b3d96d37..2d84c622 100644
--- a/typecheck.c
+++ b/typecheck.c
@@ -484,6 +484,8 @@ type_t *get_type(env_t *env, ast_t *ast)
#pragma GCC diagnostic ignored "-Wswitch-default"
switch (ast->tag) {
case Null: {
+ if (!Match(ast, Null)->type)
+ return Type(OptionalType, .type=NULL);
type_t *t = parse_type_ast(env, Match(ast, Null)->type);
return Type(OptionalType, .type=t);
}
@@ -1061,6 +1063,9 @@ type_t *get_type(env_t *env, ast_t *ast)
if (ret->tag == AbortType)
ret = Type(VoidType);
+ if (ret->tag == OptionalType && !Match(ret, OptionalType)->type)
+ code_err(lambda->body, "This function doesn't return a specific optional type");
+
if (lambda->ret_type) {
type_t *declared = parse_type_ast(env, lambda->ret_type);
if (can_promote(ret, declared))