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
This commit is contained in:
Andrew Kelley
2022-08-24 16:41:10 -07:00
parent f4980a4800
commit af19909b9c

View File

@@ -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.