From af19909b9cde3d009f0306ac825f39912644bca6 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 24 Aug 2022 16:41:10 -0700 Subject: stage2: fix generic function cleanup When removing generic function instantiations from monomorphed_funcs, we need to first make sure the function is generic, otherwise the hash map tries to access the `hash` field of the function which is undefined. closes #12614 --- src/Module.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index 45e0779c54..34617ed3e2 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -559,7 +559,9 @@ pub const Decl = struct { } if (decl.getFunction()) |func| { _ = mod.align_stack_fns.remove(func); - _ = mod.monomorphed_funcs.remove(func); + if (func.comptime_args != null) { + _ = mod.monomorphed_funcs.remove(func); + } func.deinit(gpa); gpa.destroy(func); } @@ -1478,6 +1480,7 @@ pub const Fn = struct { /// This is important because it may be accessed when resizing monomorphed_funcs /// while this Fn has already been added to the set, but does not have the /// owner_decl, comptime_args, or other fields populated yet. + /// This field is undefined if comptime_args == null. hash: u64, /// Relative to owner Decl. -- cgit v1.2.3