fix: no more deferred_return in generic parapoly type name

fix: segfault on accessing empty tags array in docs writer
This commit is contained in:
Abderrahim Indjaren
2026-05-09 23:07:50 +01:00
parent d21fea404b
commit ebd50de56c
2 changed files with 7 additions and 3 deletions

View File

@@ -2476,7 +2476,9 @@ gb_internal Type *check_get_results(CheckerContext *ctx, Scope *scope, Ast *_res
param_value = handle_parameter_value(ctx, nullptr, &type, default_value, false);
} else {
if (ctx->allow_polymorphic_types && ast_references_poly_params(ctx->scope, field->type)) {
type = alloc_type_generic(ctx->scope, 0, string_interner_insert(str_lit("$deferred_return")), nullptr);
gbString name = expr_to_string(field->type);
type = alloc_type_generic(ctx->scope, 0, string_interner_insert(make_string_c(name)), nullptr);
gb_string_free(name);
} else {
type = check_type(ctx, field->type);
}

View File

@@ -670,8 +670,10 @@ gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type, bool ca
auto tags = array_make<OdinDocString>(heap_allocator(), type->Struct.fields.count);
defer (array_free(&tags));
for_array(i, type->Struct.fields) {
tags[i] = odin_doc_write_string(w, type->Struct.tags[i]);
if (type->Struct.tags != nullptr) {
for_array(i, type->Struct.fields) {
tags[i] = odin_doc_write_string(w, type->Struct.tags[i]);
}
}
doc_type.tags = odin_write_slice(w, tags.data, tags.count);