aboutsummaryrefslogtreecommitdiff
path: root/typecheck.c
diff options
context:
space:
mode:
Diffstat (limited to 'typecheck.c')
-rw-r--r--typecheck.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/typecheck.c b/typecheck.c
index e500dfa7..9ad151a3 100644
--- a/typecheck.c
+++ b/typecheck.c
@@ -838,6 +838,12 @@ type_t *get_type(env_t *env, ast_t *ast)
else if (streq(call->name, "sorted")) return self_value_t;
code_err(ast, "There is no '%s' method for %T tables", call->name, self_value_t);
}
+ case OptionalType: {
+ type_t *nonnull = Match(self_value_t, OptionalType)->type;
+ if (streq(call->name, "or_else")) return nonnull;
+ else if (streq(call->name, "or_fail")) return nonnull;
+ code_err(ast, "There is no '%s' method for optional %T values", call->name, nonnull);
+ }
default: {
type_t *fn_type_t = get_method_type(env, call->self, call->name);
if (!fn_type_t)