2
0
Эх сурвалжийг харах

Fix polymorphic procedure generation with debug information

gingerBill 6 жил өмнө
parent
commit
57d4333ed3

+ 10 - 3
src/check_expr.cpp

@@ -265,7 +265,6 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *c, Entity *base_enti
 	}
 	}
 
 
 
 
-	bool generate_type_again = nctx.no_polymorphic_errors;
 
 
 	auto *pt = &src->Proc;
 	auto *pt = &src->Proc;
 
 
@@ -293,8 +292,12 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *c, Entity *base_enti
 		}
 		}
 	}
 	}
 
 
-
+#if 0
+	bool generate_type_again = nctx.no_polymorphic_errors;
 	if (generate_type_again) {
 	if (generate_type_again) {
+#else
+	{
+#endif
 		// LEAK TODO(bill): This is technically a memory leak as it has to generate the type twice
 		// LEAK TODO(bill): This is technically a memory leak as it has to generate the type twice
 		bool prev_no_polymorphic_errors = nctx.no_polymorphic_errors;
 		bool prev_no_polymorphic_errors = nctx.no_polymorphic_errors;
 		defer (nctx.no_polymorphic_errors = prev_no_polymorphic_errors);
 		defer (nctx.no_polymorphic_errors = prev_no_polymorphic_errors);
@@ -5004,7 +5007,11 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper
 			}
 			}
 		} else {
 		} else {
 			i64 s = 0;
 			i64 s = 0;
-			if (!check_is_assignable_to_with_score(c, o, e->type, &s)) {
+			if (is_type_generic(o->type)) {
+				// Polymorphic name!
+				score += assign_score_function(0);
+				continue;
+			} else if (!check_is_assignable_to_with_score(c, o, e->type, &s)) {
 				if (show_error) {
 				if (show_error) {
 					check_assignment(c, o, e->type, str_lit("polymorphic type argument"));
 					check_assignment(c, o, e->type, str_lit("polymorphic type argument"));
 				}
 				}

+ 1 - 1
src/ir.cpp

@@ -2712,7 +2712,7 @@ void ir_value_set_debug_location(irProcedure *proc, irValue *v) {
 					gb_printf_err("\t%.*s\n", LIT(instr->DebugDeclare.entity->token.string));
 					gb_printf_err("\t%.*s\n", LIT(instr->DebugDeclare.entity->token.string));
 				}
 				}
 			}
 			}
-			GB_PANIC("Value wihout debug location: %.*s %p; %p", LIT(proc->name), proc->entity, v);
+			GB_PANIC("Value without debug location: %.*s %p; %p :: %s", LIT(proc->name), proc->entity, v, type_to_string(proc->type));
 		}
 		}
 	}
 	}
 }
 }

+ 1 - 1
src/ir_print.cpp

@@ -236,7 +236,7 @@ bool ir_print_debug_location(irFileBuffer *f, irModule *m, irValue *v) {
 	} else {
 	} else {
 		irProcedure *proc = v->Instr.block->proc;
 		irProcedure *proc = v->Instr.block->proc;
 		if (proc->entity != nullptr) {
 		if (proc->entity != nullptr) {
-			GB_ASSERT(proc->is_entry_point || (string_compare(proc->name, str_lit(IR_STARTUP_RUNTIME_PROC_NAME)) == 0));
+			// GB_ASSERT(proc->is_entry_point || (string_compare(proc->name, str_lit(IR_STARTUP_RUNTIME_PROC_NAME)) == 0));
 		}
 		}
 	}
 	}
 	return false;
 	return false;