authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-23 00:46:05-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 18:54:36-07:00
log6d5fbb26dafae1f1d293e968a0183ae08a4e3992
treed171e4e109245d2120bc646a9d779f17b04ae751
parent9989f72c61e4c4e98c69f6191a63c201336a6a19

Maker: enhance debuggability when resolveLazyPath fails


1 files changed, 8 insertions(+), 7 deletions(-)

lib/compiler/Maker.zig+8-7
......@@ -1702,8 +1702,7 @@ pub fn resolveLazyPath(
17021702 arena: Allocator,
17031703 lazy_path: Configuration.LazyPath,
17041704 asking_step_index: Configuration.Step.Index,
1705) Allocator.Error!Path {
1706 _ = asking_step_index; // TODO use this to enhance debugability when this function fails
1705) error{ OutOfMemory, MakeFailed }!Path {
17071706 const c = &maker.scanned_config.configuration;
17081707 return switch (lazy_path) {
17091708 .source_path => |sp| try packagePath(maker, arena, sp.owner, sp.sub_path.slice(c)),
......@@ -1712,8 +1711,10 @@ pub fn resolveLazyPath(
17121711 const base = generatedPath(maker, gen.index);
17131712 var file_path = base;
17141713 for (0..gen.flags.up) |_| {
1715 file_path.sub_path = Dir.path.dirname(file_path.sub_path) orelse
1716 fatal("invalid LazyPath traversal: up {d} times from {f}", .{ gen.flags.up, base });
1714 file_path.sub_path = Dir.path.dirname(file_path.sub_path) orelse {
1715 const s = stepByIndex(maker, asking_step_index);
1716 return s.fail(maker, "invalid LazyPath traversal: up {d} times from {f}", .{ gen.flags.up, base });
1717 };
17171718 }
17181719 return file_path.join(arena, gen.sub_path.slice(c));
17191720 },
......@@ -1725,7 +1726,7 @@ pub fn resolveLazyPathIndex(
17251726 arena: Allocator,
17261727 lazy_path_index: Configuration.LazyPath.Index,
17271728 asking_step_index: Configuration.Step.Index,
1728) Allocator.Error!Path {
1729) error{ OutOfMemory, MakeFailed }!Path {
17291730 const c = &maker.scanned_config.configuration;
17301731 return resolveLazyPath(maker, arena, lazy_path_index.get(c), asking_step_index);
17311732}
......@@ -1737,7 +1738,7 @@ pub fn resolveLazyPathAbs(
17371738 arena: Allocator,
17381739 lazy_path: Configuration.LazyPath,
17391740 asking_step_index: Configuration.Step.Index,
1740) Allocator.Error![]const u8 {
1741) error{ OutOfMemory, MakeFailed }![]const u8 {
17411742 const p = try resolveLazyPath(maker, arena, lazy_path, asking_step_index);
17421743 const root_dir_path = p.root_dir.path orelse return p.subPathOrDot();
17431744 if (p.sub_path.len == 0) return root_dir_path;
......@@ -1751,7 +1752,7 @@ pub fn resolveLazyPathIndexAbs(
17511752 arena: Allocator,
17521753 lazy_path_index: Configuration.LazyPath.Index,
17531754 asking_step_index: Configuration.Step.Index,
1754) Allocator.Error![]const u8 {
1755) error{ OutOfMemory, MakeFailed }![]const u8 {
17551756 const c = &maker.scanned_config.configuration;
17561757 return resolveLazyPathAbs(maker, arena, lazy_path_index.get(c), asking_step_index);
17571758}