From ebd50de56c19bfadd14313999897ec69373f4049 Mon Sep 17 00:00:00 2001 From: Abderrahim Indjaren Date: Sat, 9 May 2026 23:07:50 +0100 Subject: [PATCH] fix: no more deferred_return in generic parapoly type name fix: segfault on accessing empty tags array in docs writer --- src/check_type.cpp | 4 +++- src/docs_writer.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/check_type.cpp b/src/check_type.cpp index a0a4bc1f2..f84644ea1 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -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); } diff --git a/src/docs_writer.cpp b/src/docs_writer.cpp index a9f3a3e15..e0b0a05c1 100644 --- a/src/docs_writer.cpp +++ b/src/docs_writer.cpp @@ -670,8 +670,10 @@ gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type, bool ca auto tags = array_make(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);