Correct parapoly determination of generated internal type of a map

This commit is contained in:
gingerBill
2022-09-22 00:05:11 +01:00
parent 0380601bb4
commit 8c3f01fbfa
7 changed files with 11 additions and 9 deletions

View File

@@ -1360,7 +1360,13 @@ bool is_polymorphic_type_assignable(CheckerContext *c, Type *poly, Type *source,
if (source->kind == Type_Map) {
bool key = is_polymorphic_type_assignable(c, poly->Map.key, source->Map.key, true, modify_type);
bool value = is_polymorphic_type_assignable(c, poly->Map.value, source->Map.value, true, modify_type);
return key || value;
if (key || value) {
poly->Map.entry_type = nullptr;
poly->Map.internal_type = nullptr;
poly->Map.lookup_result_type = nullptr;
init_map_internal_types(poly);
return true;
}
}
return false;

View File

@@ -2211,7 +2211,6 @@ void init_map_internal_types(Type *type) {
GB_ASSERT(type->kind == Type_Map);
init_map_entry_type(type);
if (type->Map.internal_type != nullptr) return;
if (type->Map.generated_struct_type != nullptr) return;
Type *key = type->Map.key;
Type *value = type->Map.value;
@@ -2239,7 +2238,6 @@ void init_map_internal_types(Type *type) {
generated_struct_type->Struct.fields = fields;
type_set_offsets(generated_struct_type);
type->Map.generated_struct_type = generated_struct_type;
type->Map.internal_type = generated_struct_type;
type->Map.lookup_result_type = make_optional_ok_type(value);
}

View File

@@ -1922,7 +1922,7 @@ void add_type_info_type_internal(CheckerContext *c, Type *t) {
init_map_internal_types(bt);
add_type_info_type_internal(c, bt->Map.key);
add_type_info_type_internal(c, bt->Map.value);
add_type_info_type_internal(c, bt->Map.generated_struct_type);
add_type_info_type_internal(c, bt->Map.internal_type);
break;
case Type_Tuple:
@@ -2144,7 +2144,7 @@ void add_min_dep_type_info(Checker *c, Type *t) {
init_map_internal_types(bt);
add_min_dep_type_info(c, bt->Map.key);
add_min_dep_type_info(c, bt->Map.value);
add_min_dep_type_info(c, bt->Map.generated_struct_type);
add_min_dep_type_info(c, bt->Map.internal_type);
break;
case Type_Tuple:

View File

@@ -521,7 +521,6 @@ lbValue lb_gen_map_header_table_internal(lbProcedure *p, Type *map_type) {
i64 value_offset = type_offset_of(map_type->Map.entry_type, 3);
i64 value_size = type_size_of (map_type->Map.value);
Type *key_type = map_type->Map.key;
Type *val_type = map_type->Map.value;
gb_unused(val_type);

View File

@@ -787,7 +787,7 @@ void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info da
tag = lb_const_ptr_cast(m, variant_ptr, t_type_info_map_ptr);
init_map_internal_types(t);
lbValue gst = lb_type_info(m, t->Map.generated_struct_type);
lbValue gst = lb_type_info(m, t->Map.internal_type);
LLVMValueRef vals[5] = {
lb_type_info(m, t->Map.key).value,

View File

@@ -1130,7 +1130,7 @@ lbValue lb_emit_struct_ev(lbProcedure *p, lbValue s, i32 index) {
case Type_Map:
{
init_map_internal_types(t);
Type *gst = t->Map.generated_struct_type;
Type *gst = t->Map.internal_type;
switch (index) {
case 0: result_type = get_struct_field_type(gst, 0); break;
case 1: result_type = get_struct_field_type(gst, 1); break;

View File

@@ -227,7 +227,6 @@ struct TypeProc {
Type *key; \
Type *value; \
Type *entry_type; \
Type *generated_struct_type; \
Type *internal_type; \
Type *lookup_result_type; \
}) \