Use RecursiveMutex to fix a race condition with parapoly records

This commit is contained in:
gingerBill
2025-09-26 10:18:46 +01:00
parent 42b9039a1f
commit 01c10f3f5e
5 changed files with 16 additions and 8 deletions

View File

@@ -1293,6 +1293,11 @@ gb_internal void check_assignment(CheckerContext *c, Operand *operand, Type *typ
error_line("\t Got: %s\n", s_got);
gb_string_free(s_got);
gb_string_free(s_expected);
Type *tx = x->Proc.params->Tuple.variables[0]->type;
Type *ty = y->Proc.params->Tuple.variables[0]->type;
gb_printf_err("%s kind:%.*s e:%p ot:%p\n", type_to_string(tx), LIT(type_strings[tx->kind]), tx->Named.type_name, tx->Named.type_name->TypeName.original_type_for_parapoly);
gb_printf_err("%s kind:%.*s e:%p ot:%p\n", type_to_string(ty), LIT(type_strings[ty->kind]), ty->Named.type_name, ty->Named.type_name->TypeName.original_type_for_parapoly);
} else {
gbString s_expected = type_to_string(y);
gbString s_got = type_to_string(x);
@@ -7908,11 +7913,10 @@ gb_internal CallArgumentError check_polymorphic_record_type(CheckerContext *c, O
{
GenTypesData *found_gen_types = ensure_polymorphic_record_entity_has_gen_types(c, original_type);
mutex_lock(&found_gen_types->mutex);
defer (mutex_unlock(&found_gen_types->mutex));
rw_mutex_shared_lock(&found_gen_types->mutex);
Entity *found_entity = find_polymorphic_record_entity(found_gen_types, param_count, ordered_operands);
rw_mutex_shared_unlock(&found_gen_types->mutex);
if (found_entity) {
operand->mode = Addressing_Type;
operand->type = found_entity->type;