summaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2019-09-22 18:58:36 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2019-09-22 18:58:36 -0400
commit8afb5378033e60a745d83142dbde4ef32ec30fbe (patch)
tree3424ed4200720f8af51140be275328c88d83a03e /types.c
parent378208b54b0c5ac52bfbb67e4c3bff5d9b747cd7 (diff)
elif, else
Diffstat (limited to 'types.c')
-rw-r--r--types.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/types.c b/types.c
index cbcd37f..51a801f 100644
--- a/types.c
+++ b/types.c
@@ -164,7 +164,7 @@ static bool type_of_ident(Typer *tr, Location where, Identifier i, Type *t, bool
bool captured = false;
if (decl->scope != NULL)
for (Block *block = tr->block; block != decl->scope; block = block->parent) {
- if (block->kind == BLOCK_FN) {
+ if (block->flags & BLOCK_FLAG_FN) {
captured = true;
break;
}
@@ -360,6 +360,20 @@ static bool type_of_expr(Typer *tr, Expression *e) {
return false;
}
}
+ if (i->kind == IFEXPR_IF && t->kind != TYPE_VOID) {
+ /* make sure there's an else at the end of this chain */
+ bool has_else = false;
+ IfExpr *curr = i;
+ do {
+ curr = &curr->next_elif->if_;
+ if (curr->kind == IFEXPR_ELSE)
+ has_else = true;
+ } while (curr->next_elif);
+ if (!has_else) {
+ err_print(e->where, "non-void if block with no else");
+ return false;
+ }
+ }
} break;
case EXPR_CALL: {
CallExpr *c = &e->call;