aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-08-24 16:41:10 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-08-24 16:47:58 -0700
commitaf19909b9cde3d009f0306ac825f39912644bca6 (patch)
tree0e6f1510b96f963375cfd60e236c2959a31d8a81 /src/Module.zig
parentf4980a480023c36692da52083f421e068e40f6b3 (diff)
downloadzig-af19909b9cde3d009f0306ac825f39912644bca6.tar.gz
zig-af19909b9cde3d009f0306ac825f39912644bca6.zip
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
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig5
1 files changed, 4 insertions, 1 deletions
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.