| ... | @@ -3367,6 +3367,8 @@ pub fn deinit(mod: *Module) void { | ... | @@ -3367,6 +3367,8 @@ pub fn deinit(mod: *Module) void { |
| 3367 | for (mod.import_table.keys()) |key| { | 3367 | for (mod.import_table.keys()) |key| { |
| 3368 | gpa.free(key); | 3368 | gpa.free(key); |
| 3369 | } | 3369 | } |
| | 3370 | var failed_decls = mod.failed_decls; |
| | 3371 | mod.failed_decls = .{}; |
| 3370 | for (mod.import_table.values()) |value| { | 3372 | for (mod.import_table.values()) |value| { |
| 3371 | value.destroy(mod); | 3373 | value.destroy(mod); |
| 3372 | } | 3374 | } |
| ... | @@ -3406,10 +3408,10 @@ pub fn deinit(mod: *Module) void { | ... | @@ -3406,10 +3408,10 @@ pub fn deinit(mod: *Module) void { |
| 3406 | mod.local_zir_cache.handle.close(); | 3408 | mod.local_zir_cache.handle.close(); |
| 3407 | mod.global_zir_cache.handle.close(); | 3409 | mod.global_zir_cache.handle.close(); |
| 3408 | | 3410 | |
| 3409 | for (mod.failed_decls.values()) |value| { | 3411 | for (failed_decls.values()) |value| { |
| 3410 | value.destroy(gpa); | 3412 | value.destroy(gpa); |
| 3411 | } | 3413 | } |
| 3412 | mod.failed_decls.deinit(gpa); | 3414 | failed_decls.deinit(gpa); |
| 3413 | | 3415 | |
| 3414 | if (mod.emit_h) |emit_h| { | 3416 | if (mod.emit_h) |emit_h| { |
| 3415 | for (emit_h.failed_decls.values()) |value| { | 3417 | for (emit_h.failed_decls.values()) |value| { |
| ... | @@ -3482,6 +3484,14 @@ pub fn deinit(mod: *Module) void { | ... | @@ -3482,6 +3484,14 @@ pub fn deinit(mod: *Module) void { |
| 3482 | pub fn destroyDecl(mod: *Module, decl_index: Decl.Index) void { | 3484 | pub fn destroyDecl(mod: *Module, decl_index: Decl.Index) void { |
| 3483 | const gpa = mod.gpa; | 3485 | const gpa = mod.gpa; |
| 3484 | { | 3486 | { |
| | 3487 | if (mod.failed_decls.contains(decl_index)) { |
| | 3488 | blk: { |
| | 3489 | const errs = mod.comp.getAllErrorsAlloc() catch break :blk; |
| | 3490 | for (errs.list) |err| Compilation.AllErrors.Message.renderToStdErr(err, .no_color); |
| | 3491 | } |
| | 3492 | // TODO restore test case triggering this panic |
| | 3493 | @panic("Zig compiler bug: attempted to destroy declaration with an attached error"); |
| | 3494 | } |
| 3485 | const decl = mod.declPtr(decl_index); | 3495 | const decl = mod.declPtr(decl_index); |
| 3486 | log.debug("destroy {*} ({s})", .{ decl, decl.name }); | 3496 | log.debug("destroy {*} ({s})", .{ decl, decl.name }); |
| 3487 | _ = mod.test_functions.swapRemove(decl_index); | 3497 | _ = mod.test_functions.swapRemove(decl_index); |