summaryrefslogtreecommitdiff
path: root/type_checker.c
diff options
context:
space:
mode:
Diffstat (limited to 'type_checker.c')
-rw-r--r--type_checker.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/type_checker.c b/type_checker.c
index d8534e2..8a07f2a 100644
--- a/type_checker.c
+++ b/type_checker.c
@@ -50,8 +50,9 @@ static void exit_scope(struct scope* child_scope) {
static const struct type_def* resolve_type_ref(struct type_ref_node* node) {
/* TODO: support pointers and such */
- if (node->def_ref == NULL) TYPE_PANIC("use of unresolved type");
- return node->def_ref;
+ if (node->type.raw_type == NULL) TYPE_PANIC("use of unresolved type");
+ if (node->type.ptr_level > 0) return ast_ref->pointer_type;
+ return node->type.raw_type;
}
static const struct type_def* resolve_int_lit(struct int_lit_node* node) {
@@ -67,7 +68,7 @@ static const struct type_def* resolve_char_lit(struct char_lit_node* node) {
}
static const struct type_def* resolve_str_lit(struct str_lit_node* node) {
- return ast_ref->string_type;
+ return ast_ref->pointer_type;
}
static const struct type_def* resolve_var_ref(struct var_ref_node* node) {
@@ -235,7 +236,7 @@ static void type_check_group(struct group_node* node) {
static void type_check_fn_decl(struct fn_decl_node* node) {
enter_scope(node->scope);
- node->return_type.def_ref = resolve_type_ref(&node->return_type);
+ node->resolved_return_type = resolve_type_ref(&node->return_type);
for (struct args_decl_node* arg_decl = node->args;
arg_decl != NULL;