CHECK 1 done

Fix panic in LLVM backend when using generic procedure with default arguments

- Fixed panic in `llvm_backend_proc.cpp` when using unspecialized polymorphic procedures as defaults.
- Ensured correct type inference when generic procedures are used as default parameters.
This commit is contained in:
bogwi
2025-05-05 14:18:11 +09:00
parent 93f80f60fb
commit ee8aeea381
3 changed files with 26 additions and 3 deletions
+10 -2
View File
@@ -885,8 +885,8 @@ gb_internal void lb_addr_store(lbProcedure *p, lbAddr addr, lbValue value) {
Type *t = base_type(type_deref(addr.addr.type));
GB_ASSERT(t->kind == Type_Struct && t->Struct.soa_kind != StructSoa_None);
lbValue len = lb_soa_struct_len(p, addr.addr);
if (addr.soa.index_expr != nullptr) {
lb_emit_bounds_check(p, ast_token(addr.soa.index_expr), index, len);
if (addr.soa.index_expr != nullptr && (!lb_is_const(addr.soa.index) || t->Struct.soa_kind != StructSoa_Fixed)) {
lb_emit_bounds_check(p, ast_token(addr.soa.index_expr), addr.soa.index, len);
}
}
@@ -2728,6 +2728,14 @@ gb_internal lbValue lb_find_procedure_value_from_entity(lbModule *m, Entity *e)
ignore_body = other_module != m;
lbProcedure *missing_proc = lb_create_procedure(m, e, ignore_body);
if (missing_proc == nullptr) {
// This is an unspecialized polymorphic procedure, which should not be codegen'd
lbValue dummy = {};
dummy.value = nullptr;
dummy.type = nullptr;
return dummy;
}
if (ignore_body) {
mutex_lock(&gen->anonymous_proc_lits_mutex);
defer (mutex_unlock(&gen->anonymous_proc_lits_mutex));