aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.c1
-rw-r--r--src/semantic.c4
2 files changed, 4 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index fc991d2..7878c57 100644
--- a/src/main.c
+++ b/src/main.c
@@ -52,6 +52,7 @@ process_source(const StringView *source, const char *file_name) {
52 52
53 // Symbol table generation and type checking. 53 // Symbol table generation and type checking.
54 ParseTree *parse_tree = semantic_analysis(roots); 54 ParseTree *parse_tree = semantic_analysis(roots);
55 check_errors(file_name);
55 if (mode == PRINT_SEMANTIC) { 56 if (mode == PRINT_SEMANTIC) {
56 viz_ast(parse_tree->roots); 57 viz_ast(parse_tree->roots);
57 return; 58 return;
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;