From 86746702f053c88fe99787bd278aedeba7fcda7d Mon Sep 17 00:00:00 2001 From: Charlie Gordon Date: Wed, 28 Jan 2026 10:27:51 +0100 Subject: [PATCH] Compiler: bug fixes * fix incorrect order in `defKind_names` * remove debug output in `TypeRef.diagName` * fix use after free in `ast.deinit` --- ast/function_decl.c2 | 2 +- ast/type_ref.c2 | 3 +-- ast/utils.c2 | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ast/function_decl.c2 b/ast/function_decl.c2 index 6a46b897b..ca1b482de 100644 --- a/ast/function_decl.c2 +++ b/ast/function_decl.c2 @@ -49,8 +49,8 @@ const char*[] defKind_names = { "global", "type", "struct-member", - "template", "param", + "template", } type FunctionDeclBits struct { diff --git a/ast/type_ref.c2 b/ast/type_ref.c2 index 6b63b37e2..af04cfcd4 100644 --- a/ast/type_ref.c2 +++ b/ast/type_ref.c2 @@ -17,7 +17,7 @@ module ast; import src_loc local; import string_buffer; -import stdio; + import string; public type TypeRefKind enum u8 { @@ -538,7 +538,6 @@ public fn const char* TypeRef.diagName(const TypeRef* r) { local char[128] result; string_buffer.Buf buf.init(result, elemsof(result), false, false, 0); r.print(&buf, true); - stdio.puts(result); return result; } diff --git a/ast/utils.c2 b/ast/utils.c2 index c2bc2b932..8ef593ef8 100644 --- a/ast/utils.c2 +++ b/ast/utils.c2 @@ -188,8 +188,9 @@ public fn void deinit(bool print_stats) { globals.ast_list = nil; globals.pointers.clear(); globals.string_types.clear(); - stdlib.free(globals); globals.dump_buf.free(); + stdlib.free(globals); + globals = nil; } public fn u32 getWordSize() {