diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2022-10-29 05:58:41 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2022-10-29 05:58:41 -0400 |
| commit | 48a2783969b0a43200514a5b4e9cce57be4e5b46 (patch) | |
| tree | 0f7cc577dd9090938d842250e1d1986d3d05aa0e /src/Module.zig | |
| parent | e20d2b3151607fe078b43331ea27d5b34f95360b (diff) | |
| parent | 20925b2f5c5c0ae20fdc0574e5d4e5740d17b4d6 (diff) | |
| download | zig-48a2783969b0a43200514a5b4e9cce57be4e5b46.tar.gz zig-48a2783969b0a43200514a5b4e9cce57be4e5b46.zip | |
cbe: implement optional slice representation change
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Module.zig b/src/Module.zig index 4f150b0148..a8ea63ffc9 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -3367,6 +3367,8 @@ pub fn deinit(mod: *Module) void { for (mod.import_table.keys()) |key| { gpa.free(key); } + var failed_decls = mod.failed_decls; + mod.failed_decls = .{}; for (mod.import_table.values()) |value| { value.destroy(mod); } @@ -3406,10 +3408,10 @@ pub fn deinit(mod: *Module) void { mod.local_zir_cache.handle.close(); mod.global_zir_cache.handle.close(); - for (mod.failed_decls.values()) |value| { + for (failed_decls.values()) |value| { value.destroy(gpa); } - mod.failed_decls.deinit(gpa); + failed_decls.deinit(gpa); if (mod.emit_h) |emit_h| { for (emit_h.failed_decls.values()) |value| { @@ -3482,6 +3484,14 @@ pub fn deinit(mod: *Module) void { pub fn destroyDecl(mod: *Module, decl_index: Decl.Index) void { const gpa = mod.gpa; { + if (mod.failed_decls.contains(decl_index)) { + blk: { + const errs = mod.comp.getAllErrorsAlloc() catch break :blk; + for (errs.list) |err| Compilation.AllErrors.Message.renderToStdErr(err, .no_color); + } + // TODO restore test case triggering this panic + @panic("Zig compiler bug: attempted to destroy declaration with an attached error"); + } const decl = mod.declPtr(decl_index); log.debug("destroy {*} ({s})", .{ decl, decl.name }); _ = mod.test_functions.swapRemove(decl_index); |
