diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 17ad25c58..cb9fce7b6 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -5599,6 +5599,8 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper } if (minimum_param_count != param_count) { + array_resize(&ordered_operands, param_count); + isize missing_count = 0; // NOTE(bill): Replace missing operands with the default values (if possible) for_array(i, ordered_operands) { @@ -5613,6 +5615,11 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper if (e->Constant.param_value.kind == ParameterValue_Constant) { o->value = e->Constant.param_value.value; } + } else if (e->kind == Entity_TypeName) { + missing_count += 1; + o->mode = Addressing_Type; + o->type = e->type; + o->expr = e->identifier; } } } diff --git a/src/check_type.cpp b/src/check_type.cpp index 4822b3f0d..a1b446ad2 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -241,6 +241,8 @@ Entity *find_polymorphic_record_entity(CheckerContext *ctx, Type *original_type, auto *found_gen_types = map_get(&ctx->info->gen_types, hash_pointer(original_type)); if (found_gen_types != nullptr) { + // GB_ASSERT_MSG(ordered_operands.count >= param_count, "%td >= %td", ordered_operands.count, param_count); + for_array(i, *found_gen_types) { Entity *e = (*found_gen_types)[i]; Type *t = base_type(e->type); @@ -249,13 +251,14 @@ Entity *find_polymorphic_record_entity(CheckerContext *ctx, Type *original_type, bool skip = false; - GB_ASSERT(ordered_operands.count >= param_count); - for (isize j = 0; j < param_count; j++) { Entity *p = tuple->variables[j]; - Operand o = ordered_operands[j]; + Operand o = {}; + if (j < ordered_operands.count) { + o = ordered_operands[j]; + } if (o.expr == nullptr) { - return nullptr; + continue; } Entity *oe = entity_of_node(o.expr); if (p == oe) { diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index 99f824c35..5b922de4b 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -2021,7 +2021,7 @@ lbValue lb_build_call_expr_internal(lbProcedure *p, Ast *expr) { for_array(i, ce->args) { Ast *arg = ce->args[i]; TypeAndValue tav = type_and_value_of_expr(arg); - GB_ASSERT_MSG(tav.mode != Addressing_Invalid, "%s %s", expr_to_string(arg), expr_to_string(expr)); + GB_ASSERT_MSG(tav.mode != Addressing_Invalid, "%s %s %d", expr_to_string(arg), expr_to_string(expr), tav.mode); GB_ASSERT_MSG(tav.mode != Addressing_ProcGroup, "%s", expr_to_string(arg)); Type *at = tav.type; if (at->kind == Type_Tuple) {