diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig index 5dd273fc380e8bc7611cc3919ef30031965a284b..ed10d9b70dbf0abd45a48824fbe7731bdd8ffc44 100644 --- a/src/Zcu/PerThread.zig +++ b/src/Zcu/PerThread.zig @@ -1872,15 +1872,22 @@ fn analyzeNavVal( // that case and invalidate the dependee right now. if (zcu.clearOutdatedState(.wrap(.{ .nav_ty = nav_id }))) { assert(zir_decl.type_body == null); // otherwise we already resolved it with `Sema.ensureNavResolved` - zcu.resetUnit(.wrap(.{ .nav_ty = nav_id })); - try pt.addDependency(.wrap(.{ .nav_ty = nav_id }), .{ .nav_val = nav_id }); // inferred type depends on the value (that's us!) + const type_unit: AnalUnit = .wrap(.{ .nav_ty = nav_id }); + const prev_type_failed = zcu.failed_analysis.contains(type_unit) or + zcu.transitive_failed_analysis.contains(type_unit); + zcu.resetUnit(type_unit); + try pt.addDependency(type_unit, .{ .nav_val = nav_id }); // inferred type depends on the value (that's us!) if (comp.debugIncremental()) { - const info = try zcu.incremental_debug_state.getUnitInfo(gpa, .wrap(.{ .nav_ty = nav_id })); + const info = try zcu.incremental_debug_state.getUnitInfo(gpa, type_unit); info.last_update_gen = zcu.generation; info.deps.clearRetainingCapacity(); } - const type_changed: bool = if (old_nav.resolved) |r| r.type != nav_ty.toIntern() else true; - if (type_changed) { + const type_outdated: bool = type_outdated: { + if (prev_type_failed) break :type_outdated true; + const r = old_nav.resolved orelse break :type_outdated true; + break :type_outdated r.type != nav_ty.toIntern(); + }; + if (type_outdated) { try zcu.markDependeeOutdated(.marked_po, .{ .nav_ty = nav_id }); } else { try zcu.markPoDependeeUpToDate(.{ .nav_ty = nav_id }); diff --git a/test/incremental/pointer_to_decl_with_astgen_error b/test/incremental/pointer_to_decl_with_astgen_error new file mode 100644 index 0000000000000000000000000000000000000000..6c9359209b7fa7e83de855a3e4680f31c566fa5c --- /dev/null +++ b/test/incremental/pointer_to_decl_with_astgen_error @@ -0,0 +1,23 @@ +#update=initial version +#file=main.zig +const foo = {}; +pub fn main() void { + _ = &foo; +} +#expect_stdout="" + +#update=introduce use of undeclared identifier +#file=main.zig +const foo = something; +pub fn main() void { + _ = &foo; +} +#expect_error=main.zig:1:13: error: use of undeclared identifier 'something' + +#update=revert use of undeclared identifier +#file=main.zig +const foo = {}; +pub fn main() void { + _ = &foo; +} +#expect_stdout=""