aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-12-22 14:16:56 +0000
committergingerBill <bill@gingerbill.org>2019-12-22 14:16:56 +0000
commit1d14b3059e0e4310ffc061ca606d2eb6a153149d (patch)
tree237d6f97cbd33f5888d78399005fc2ee637b0b80 /src
parentcc2fa8f7564b937601f87bd2611f7ddb88594043 (diff)
Fix Internal Compiler Error: Type_Info for 'XXX' could not be found #507
Diffstat (limited to 'src')
-rw-r--r--src/checker.cpp15
-rw-r--r--src/checker.hpp2
-rw-r--r--src/ir.cpp12
3 files changed, 18 insertions, 11 deletions
diff --git a/src/checker.cpp b/src/checker.cpp
index 675857cf4..ec6e5d4d0 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -1435,7 +1435,12 @@ void add_min_dep_type_info(Checker *c, Type *t) {
auto *set = &c->info.minimum_dependency_type_info_set;
- isize ti_index = type_info_index(&c->info, t);
+ isize ti_index = type_info_index(&c->info, t, false);
+ if (ti_index < 0) {
+ add_type_info_type(&c->init_ctx, t); // Missing the type information
+ ti_index = type_info_index(&c->info, t, false);
+ }
+ GB_ASSERT(ti_index >= 0);
if (ptr_set_exists(set, ti_index)) {
// Type Already exists
return;
@@ -1528,16 +1533,16 @@ void add_min_dep_type_info(Checker *c, Type *t) {
break;
case Type_Struct:
+ for_array(i, bt->Struct.fields) {
+ Entity *f = bt->Struct.fields[i];
+ add_min_dep_type_info(c, f->type);
+ }
if (bt->Struct.scope != nullptr) {
for_array(i, bt->Struct.scope->elements.entries) {
Entity *e = bt->Struct.scope->elements.entries[i].value;
add_min_dep_type_info(c, e->type);
}
}
- for_array(i, bt->Struct.fields) {
- Entity *f = bt->Struct.fields[i];
- add_min_dep_type_info(c, f->type);
- }
break;
case Type_BitFieldValue:
diff --git a/src/checker.hpp b/src/checker.hpp
index da206a867..d95a703e9 100644
--- a/src/checker.hpp
+++ b/src/checker.hpp
@@ -330,7 +330,7 @@ DeclInfo * decl_info_of_ident (Ast *ident);
DeclInfo * decl_info_of_entity (Entity * e);
AstFile * ast_file_of_filename (CheckerInfo *i, String filename);
// IMPORTANT: Only to use once checking is done
-isize type_info_index (CheckerInfo *i, Type * type, bool error_on_failure = true);
+isize type_info_index (CheckerInfo *i, Type *type, bool error_on_failure);
// Will return nullptr if not found
Entity *entity_of_node(Ast *expr);
diff --git a/src/ir.cpp b/src/ir.cpp
index 9e21e58bd..79b19cabf 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -5800,11 +5800,13 @@ isize ir_type_info_count(CheckerInfo *info) {
}
isize ir_type_info_index(CheckerInfo *info, Type *type, bool err_on_not_found=true) {
- isize index = type_info_index(info, type);
- auto *set = &info->minimum_dependency_type_info_set;
- for_array(i, set->entries) {
- if (set->entries[i].ptr == index) {
- return i+1;
+ isize index = type_info_index(info, type, false);
+ if (index >= 0) {
+ auto *set = &info->minimum_dependency_type_info_set;
+ for_array(i, set->entries) {
+ if (set->entries[i].ptr == index) {
+ return i+1;
+ }
}
}
if (err_on_not_found) {