authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-24 16:41:10-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-24 16:47:58-07:00
logaf19909b9cde3d009f0306ac825f39912644bca6
tree0e6f1510b96f963375cfd60e236c2959a31d8a81
parentf4980a480023c36692da52083f421e068e40f6b3

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

1 files changed, 4 insertions(+), 1 deletions(-)

src/Module.zig+4-1
...@@ -559,7 +559,9 @@ pub const Decl = struct {...@@ -559,7 +559,9 @@ pub const Decl = struct {
559 }559 }
560 if (decl.getFunction()) |func| {560 if (decl.getFunction()) |func| {
561 _ = mod.align_stack_fns.remove(func);561 _ = mod.align_stack_fns.remove(func);
562 _ = mod.monomorphed_funcs.remove(func);562 if (func.comptime_args != null) {
563 _ = mod.monomorphed_funcs.remove(func);
564 }
563 func.deinit(gpa);565 func.deinit(gpa);
564 gpa.destroy(func);566 gpa.destroy(func);
565 }567 }
...@@ -1478,6 +1480,7 @@ pub const Fn = struct {...@@ -1478,6 +1480,7 @@ pub const Fn = struct {
1478 /// This is important because it may be accessed when resizing monomorphed_funcs1480 /// This is important because it may be accessed when resizing monomorphed_funcs
1479 /// while this Fn has already been added to the set, but does not have the1481 /// while this Fn has already been added to the set, but does not have the
1480 /// owner_decl, comptime_args, or other fields populated yet.1482 /// owner_decl, comptime_args, or other fields populated yet.
1483 /// This field is undefined if comptime_args == null.
1481 hash: u64,1484 hash: u64,
14821485
1483 /// Relative to owner Decl.1486 /// Relative to owner Decl.