aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-03-25 13:23:43 +0000
committergingerBill <bill@gingerbill.org>2024-03-25 13:23:43 +0000
commite5629dafd0be1be42a3bd183a09ff82492b6b386 (patch)
treef535e5de4dfc558531ef5052c6a14da798526e26 /src/check_expr.cpp
parent68ff9454198e9eb02f46dac1777f68c594c60915 (diff)
Potentially fix a race condition with parapoly types (related to #3328)
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index fd10374c1..44d65e376 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -79,7 +79,6 @@ gb_internal Type * check_type_expr (CheckerContext *c, Ast *exp
gb_internal Type * make_optional_ok_type (Type *value, bool typed=true);
gb_internal Entity * check_selector (CheckerContext *c, Operand *operand, Ast *node, Type *type_hint);
gb_internal Entity * check_ident (CheckerContext *c, Operand *o, Ast *n, Type *named_type, Type *type_hint, bool allow_import_name);
-gb_internal Entity * find_polymorphic_record_entity (CheckerContext *c, Type *original_type, isize param_count, Array<Operand> const &ordered_operands, bool *failure);
gb_internal void check_not_tuple (CheckerContext *c, Operand *operand);
gb_internal void convert_to_typed (CheckerContext *c, Operand *operand, Type *target_type);
gb_internal gbString expr_to_string (Ast *expression);
@@ -121,6 +120,8 @@ gb_internal isize get_procedure_param_count_excluding_defaults(Type *pt, isize *
gb_internal bool is_expr_inferred_fixed_array(Ast *type_expr);
+gb_internal Entity *find_polymorphic_record_entity(GenTypesData *found_gen_types, isize param_count, Array<Operand> const &ordered_operands);
+
enum LoadDirectiveResult {
LoadDirective_Success = 0,
LoadDirective_Error = 1,
@@ -7171,8 +7172,12 @@ gb_internal CallArgumentError check_polymorphic_record_type(CheckerContext *c, O
}
{
- bool failure = false;
- Entity *found_entity = find_polymorphic_record_entity(c, original_type, param_count, ordered_operands, &failure);
+ 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));
+ Entity *found_entity = find_polymorphic_record_entity(found_gen_types, param_count, ordered_operands);
+
if (found_entity) {
operand->mode = Addressing_Type;
operand->type = found_entity->type;