gingerBill 4 years ago
parent
commit
8ff9f2e44f
3 changed files with 15 additions and 5 deletions
  1. 7 0
      src/check_expr.cpp
  2. 7 4
      src/check_type.cpp
  3. 1 1
      src/llvm_backend_proc.cpp

+ 7 - 0
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;
 				}
 			}
 		}

+ 7 - 4
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) {

+ 1 - 1
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) {