diff options
Diffstat (limited to 'src/semantic.c')
-rw-r--r-- | src/semantic.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/semantic.c b/src/semantic.c index 6c9f290..dd95d28 100644 --- a/src/semantic.c +++ b/src/semantic.c | |||
@@ -311,6 +311,8 @@ resolve_type(ParseTree *ast, Scope *scope, Node *node) { | |||
311 | node->expr_type = type; | 311 | node->expr_type = type; |
312 | } break; | 312 | } break; |
313 | case NODE_FUN: { | 313 | case NODE_FUN: { |
314 | node->expr_type = &default_types[TYPE_VOID]; | ||
315 | |||
314 | // Fill up new scope with parameters | 316 | // Fill up new scope with parameters |
315 | scope = alloc_scope(scope); | 317 | scope = alloc_scope(scope); |
316 | array_push(ast->scopes, scope); | 318 | array_push(ast->scopes, scope); |
@@ -336,7 +338,7 @@ resolve_type(ParseTree *ast, Scope *scope, Node *node) { | |||
336 | } | 338 | } |
337 | } | 339 | } |
338 | Node *last_expr = body->block.expr[array_size(body->block.expr) - 1]; | 340 | Node *last_expr = body->block.expr[array_size(body->block.expr) - 1]; |
339 | node->expr_type = last_expr->expr_type; | 341 | node->fun.body->expr_type = last_expr->expr_type; |
340 | } else { | 342 | } else { |
341 | if (!resolve_type(ast, scope, body)) { | 343 | if (!resolve_type(ast, scope, body)) { |
342 | return false; | 344 | return false; |