aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-01-12 16:06:09 +0000
committergingerBill <bill@gingerbill.org>2023-01-12 16:06:09 +0000
commit34f917018980ceca73e9eaacacd44efab2a1448b (patch)
tree72a6d3fe248a20279323d0b6e3d348877914ff13 /src
parent38136e15fca0ee952702c4fccc0a0c6c11565746 (diff)
Fix race condition with polymorphic record generation
Diffstat (limited to 'src')
-rw-r--r--src/check_type.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index c536bf09f..9ce6585f2 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -380,8 +380,7 @@ gb_internal void add_polymorphic_record_entity(CheckerContext *ctx, Ast *node, T
gb_internal Type *check_record_polymorphic_params(CheckerContext *ctx, Ast *polymorphic_params,
bool *is_polymorphic_,
- Ast *node, Array<Operand> *poly_operands,
- Type *named_type, Type *original_type_for_poly) {
+ Ast *node, Array<Operand> *poly_operands) {
Type *polymorphic_params_type = nullptr;
bool can_check_fields = true;
GB_ASSERT(is_polymorphic_ != nullptr);
@@ -548,11 +547,6 @@ gb_internal Type *check_record_polymorphic_params(CheckerContext *ctx, Ast *poly
}
}
- if (original_type_for_poly != nullptr) {
- GB_ASSERT(named_type != nullptr);
- add_polymorphic_record_entity(ctx, node, named_type, original_type_for_poly);
- }
-
if (!*is_polymorphic_) {
*is_polymorphic_ = polymorphic_params != nullptr && poly_operands == nullptr;
}
@@ -620,10 +614,13 @@ gb_internal void check_struct_type(CheckerContext *ctx, Type *struct_type, Ast *
struct_type->Struct.polymorphic_params = check_record_polymorphic_params(
ctx, st->polymorphic_params,
&struct_type->Struct.is_polymorphic,
- node, poly_operands,
- named_type, original_type_for_poly
- );;
+ node, poly_operands
+ );
struct_type->Struct.is_poly_specialized = check_record_poly_operand_specialization(ctx, struct_type, poly_operands, &struct_type->Struct.is_polymorphic);
+ if (original_type_for_poly) {
+ GB_ASSERT(named_type != nullptr);
+ add_polymorphic_record_entity(ctx, node, named_type, original_type_for_poly);
+ }
if (!struct_type->Struct.is_polymorphic) {
if (st->where_clauses.count > 0 && st->polymorphic_params == nullptr) {
@@ -655,10 +652,13 @@ gb_internal void check_union_type(CheckerContext *ctx, Type *union_type, Ast *no
union_type->Union.polymorphic_params = check_record_polymorphic_params(
ctx, ut->polymorphic_params,
&union_type->Union.is_polymorphic,
- node, poly_operands,
- named_type, original_type_for_poly
+ node, poly_operands
);
union_type->Union.is_poly_specialized = check_record_poly_operand_specialization(ctx, union_type, poly_operands, &union_type->Union.is_polymorphic);
+ if (original_type_for_poly) {
+ GB_ASSERT(named_type != nullptr);
+ add_polymorphic_record_entity(ctx, node, named_type, original_type_for_poly);
+ }
if (!union_type->Union.is_polymorphic) {
if (ut->where_clauses.count > 0 && ut->polymorphic_params == nullptr) {