authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-07-04 10:31:59+01:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-07-09 12:53:19-04:00
log47846bc17c54d50886b702b5994c00ca8670c82b
tree5391b8a215ca8d2845a4ea6ee5fa5db14d3aee99
parent854e86c5676de82bc46b5c13a0c9c807596e438d

Zcu: fix passing exported decls with compile errors to the backend


1 files changed, 19 insertions(+), 0 deletions(-)

src/Zcu/PerThread.zig+19
......@@ -2098,6 +2098,25 @@ fn processExportsInner(
20982098 gop.value_ptr.* = export_idx;
20992099 }
21002100 }
2101
2102 switch (exported) {
2103 .decl_index => |idx| if (failed: {
2104 const decl = zcu.declPtr(idx);
2105 if (decl.analysis != .complete) break :failed true;
2106 // Check if has owned function
2107 if (!decl.owns_tv) break :failed false;
2108 if (decl.typeOf(zcu).zigTypeTag(zcu) != .Fn) break :failed false;
2109 // Check if owned function failed
2110 const a = zcu.funcInfo(decl.val.toIntern()).analysis(&zcu.intern_pool);
2111 break :failed a.state != .success;
2112 }) {
2113 // This `Decl` is failed, so was never sent to codegen.
2114 // TODO: we should probably tell the backend to delete any old exports of this `Decl`?
2115 return;
2116 },
2117 .value => {},
2118 }
2119
21012120 if (zcu.comp.bin_file) |lf| {
21022121 try zcu.handleUpdateExports(export_indices, lf.updateExports(pt, exported, export_indices));
21032122 } else if (zcu.llvm_object) |llvm_object| {