From 2a6b91874ae970c0fba63f8c1357da5a57feec27 Mon Sep 17 00:00:00 2001 From: mlugg Date: Sat, 3 Jun 2023 15:46:16 +0100 Subject: stage2: pass most test cases under InternPool All but 2 test cases now pass (tested on x86_64 Linux, native only). The remaining two signify an issue requiring a larger refactor, which I will do in a separate commit. Notable changes: * Fix uninitialized memory when allocating objects from free lists * Implement TypedValue printing for pointers * Fix some TypedValue printing logic * Work around non-existence of InternPool.remove implementation --- src/Module.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index c1d6b8157a..cb3e8884e3 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -4374,7 +4374,8 @@ pub fn semaFile(mod: *Module, file: *File) SemaError!void { .index = struct_index.toOptional(), .namespace = new_namespace_index.toOptional(), } }); - errdefer mod.intern_pool.remove(struct_ty); + // TODO: figure out InternPool removals for incremental compilation + //errdefer mod.intern_pool.remove(struct_ty); new_namespace.ty = struct_ty.toType(); file.root_decl = new_decl_index.toOptional(); @@ -5682,7 +5683,10 @@ fn markOutdatedDecl(mod: *Module, decl_index: Decl.Index) !void { } pub fn createNamespace(mod: *Module, initialization: Namespace) !Namespace.Index { - if (mod.namespaces_free_list.popOrNull()) |index| return index; + if (mod.namespaces_free_list.popOrNull()) |index| { + mod.allocated_namespaces.at(@enumToInt(index)).* = initialization; + return index; + } const ptr = try mod.allocated_namespaces.addOne(mod.gpa); ptr.* = initialization; return @intToEnum(Namespace.Index, mod.allocated_namespaces.len - 1); -- cgit v1.2.3