authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-01-04 00:06:24+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-01-04 05:44:29+00:00
logfd62912787ee4f26b06ba86560e9aa605095ae04
tree5eaeee5c1d341f68b7e0f497ee4b739f65416fd6
parentf818098971fdafdaaa6af4b927f2cf47332ed5f7
signaturelock-open Commit is signed but in an unrecognized format.

incremental: correctly handle losing file root `struct_decl` inst


1 files changed, 12 insertions(+), 3 deletions(-)

src/Zcu/PerThread.zig+12-3
...@@ -545,10 +545,19 @@ pub fn updateZirRefs(pt: Zcu.PerThread) Allocator.Error!void {...@@ -545,10 +545,19 @@ pub fn updateZirRefs(pt: Zcu.PerThread) Allocator.Error!void {
545pub fn ensureFileAnalyzed(pt: Zcu.PerThread, file_index: Zcu.File.Index) Zcu.SemaError!void {545pub fn ensureFileAnalyzed(pt: Zcu.PerThread, file_index: Zcu.File.Index) Zcu.SemaError!void {
546 const file_root_type = pt.zcu.fileRootType(file_index);546 const file_root_type = pt.zcu.fileRootType(file_index);
547 if (file_root_type != .none) {547 if (file_root_type != .none) {
548 _ = try pt.ensureTypeUpToDate(file_root_type);548 if (pt.ensureTypeUpToDate(file_root_type)) |_| {
549 } else {549 return;
550 return pt.semaFile(file_index);550 } else |err| switch (err) {
551 error.AnalysisFail => {
552 // The file's root `struct_decl` has, at some point, been lost, because the file failed AstGen.
553 // Clear `file_root_type`, and try the `semaFile` call below, in case the instruction has since
554 // been discovered under a new `TrackedInst.Index`.
555 pt.zcu.setFileRootType(file_index, .none);
556 },
557 else => |e| return e,
558 }
551 }559 }
560 return pt.semaFile(file_index);
552}561}
553562
554/// Ensures that the state of the given `ComptimeUnit` is fully up-to-date, performing re-analysis563/// Ensures that the state of the given `ComptimeUnit` is fully up-to-date, performing re-analysis