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(...@@ -1702,8 +1702,7 @@ pub fn resolveLazyPath(
1702 arena: Allocator,1702 arena: Allocator,
1703 lazy_path: Configuration.LazyPath,1703 lazy_path: Configuration.LazyPath,
1704 asking_step_index: Configuration.Step.Index,1704 asking_step_index: Configuration.Step.Index,
1705) Allocator.Error!Path {1705) error{ OutOfMemory, MakeFailed }!Path {
1706 _ = asking_step_index; // TODO use this to enhance debugability when this function fails
1707 const c = &maker.scanned_config.configuration;1706 const c = &maker.scanned_config.configuration;
1708 return switch (lazy_path) {1707 return switch (lazy_path) {
1709 .source_path => |sp| try packagePath(maker, arena, sp.owner, sp.sub_path.slice(c)),1708 .source_path => |sp| try packagePath(maker, arena, sp.owner, sp.sub_path.slice(c)),
...@@ -1712,8 +1711,10 @@ pub fn resolveLazyPath(...@@ -1712,8 +1711,10 @@ pub fn resolveLazyPath(
1712 const base = generatedPath(maker, gen.index);1711 const base = generatedPath(maker, gen.index);
1713 var file_path = base;1712 var file_path = base;
1714 for (0..gen.flags.up) |_| {1713 for (0..gen.flags.up) |_| {
1715 file_path.sub_path = Dir.path.dirname(file_path.sub_path) orelse1714 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 });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 };
1717 }1718 }
1718 return file_path.join(arena, gen.sub_path.slice(c));1719 return file_path.join(arena, gen.sub_path.slice(c));
1719 },1720 },
...@@ -1725,7 +1726,7 @@ pub fn resolveLazyPathIndex(...@@ -1725,7 +1726,7 @@ pub fn resolveLazyPathIndex(
1725 arena: Allocator,1726 arena: Allocator,
1726 lazy_path_index: Configuration.LazyPath.Index,1727 lazy_path_index: Configuration.LazyPath.Index,
1727 asking_step_index: Configuration.Step.Index,1728 asking_step_index: Configuration.Step.Index,
1728) Allocator.Error!Path {1729) error{ OutOfMemory, MakeFailed }!Path {
1729 const c = &maker.scanned_config.configuration;1730 const c = &maker.scanned_config.configuration;
1730 return resolveLazyPath(maker, arena, lazy_path_index.get(c), asking_step_index);1731 return resolveLazyPath(maker, arena, lazy_path_index.get(c), asking_step_index);
1731}1732}
...@@ -1737,7 +1738,7 @@ pub fn resolveLazyPathAbs(...@@ -1737,7 +1738,7 @@ pub fn resolveLazyPathAbs(
1737 arena: Allocator,1738 arena: Allocator,
1738 lazy_path: Configuration.LazyPath,1739 lazy_path: Configuration.LazyPath,
1739 asking_step_index: Configuration.Step.Index,1740 asking_step_index: Configuration.Step.Index,
1740) Allocator.Error![]const u8 {1741) error{ OutOfMemory, MakeFailed }![]const u8 {
1741 const p = try resolveLazyPath(maker, arena, lazy_path, asking_step_index);1742 const p = try resolveLazyPath(maker, arena, lazy_path, asking_step_index);
1742 const root_dir_path = p.root_dir.path orelse return p.subPathOrDot();1743 const root_dir_path = p.root_dir.path orelse return p.subPathOrDot();
1743 if (p.sub_path.len == 0) return root_dir_path;1744 if (p.sub_path.len == 0) return root_dir_path;
...@@ -1751,7 +1752,7 @@ pub fn resolveLazyPathIndexAbs(...@@ -1751,7 +1752,7 @@ pub fn resolveLazyPathIndexAbs(
1751 arena: Allocator,1752 arena: Allocator,
1752 lazy_path_index: Configuration.LazyPath.Index,1753 lazy_path_index: Configuration.LazyPath.Index,
1753 asking_step_index: Configuration.Step.Index,1754 asking_step_index: Configuration.Step.Index,
1754) Allocator.Error![]const u8 {1755) error{ OutOfMemory, MakeFailed }![]const u8 {
1755 const c = &maker.scanned_config.configuration;1756 const c = &maker.scanned_config.configuration;
1756 return resolveLazyPathAbs(maker, arena, lazy_path_index.get(c), asking_step_index);1757 return resolveLazyPathAbs(maker, arena, lazy_path_index.get(c), asking_step_index);
1757}1758}