diff options
| author | Martin Wickham <spexguy070@gmail.com> | 2021-09-30 23:38:41 -0500 |
|---|---|---|
| committer | Martin Wickham <spexguy070@gmail.com> | 2021-10-02 15:21:48 -0500 |
| commit | 806eee8e99fbbd86f01b62b4306bd48f1cd3c872 (patch) | |
| tree | b01b196ea547979bcb23be1454a3d6780ed6f196 /src/Module.zig | |
| parent | 8d42500699939028aaf78e9463326820b6d08353 (diff) | |
| download | zig-806eee8e99fbbd86f01b62b4306bd48f1cd3c872.tar.gz zig-806eee8e99fbbd86f01b62b4306bd48f1cd3c872.zip | |
Fix abortAnonDecl()
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/Module.zig b/src/Module.zig index 07ebb0823c..60dea31d18 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -4064,9 +4064,19 @@ pub fn deleteUnusedDecl(mod: *Module, decl: *Decl) void { pub fn abortAnonDecl(mod: *Module, decl: *Decl) void { log.debug("abortAnonDecl {*} ({s})", .{ decl, decl.name }); - assert(decl.namespace.anon_decls.swapRemove(decl)); - assert(decl.dependants.count() == 0); - assert(decl.dependencies.count() == 0); + + const owner_namespace = if (decl.namespace.getDecl() == decl and decl.namespace.parent != null) decl.namespace.parent.? else decl.namespace; + assert(owner_namespace.anon_decls.swapRemove(decl)); + + const dependants = decl.dependants.keys(); + for (dependants) |dep| { + dep.removeDependency(decl); + } + + for (decl.dependencies.keys()) |dep| { + dep.removeDependant(decl); + } + decl.destroy(mod); } |
