aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-10-05 09:41:03 -0400
committerGitHub <noreply@github.com>2022-10-05 09:41:03 -0400
commit3234e8de3a50575195fab625f818a6e5fe141c7b (patch)
tree68a5a69cee94e1ecaf6ff725cc55ce5ebd2cd9e6 /src/Module.zig
parente563af13296cdb3e64f0f396fdc58112d4484968 (diff)
parent6152f043c0446ace7c992c33f27174152d9bd8a0 (diff)
downloadzig-3234e8de3a50575195fab625f818a6e5fe141c7b.tar.gz
zig-3234e8de3a50575195fab625f818a6e5fe141c7b.zip
Merge pull request #13071 from ziglang/resolve-cache-files
stage2: resolve file before putting them into cache
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 81a9ec220b..9ab2a859f8 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -4478,9 +4478,17 @@ pub fn semaFile(mod: *Module, file: *File) SemaError!void {
try reportRetryableFileError(mod, file, "unable to load source: {s}", .{@errorName(err)});
return error.AnalysisFail;
};
- const resolved_path = try file.pkg.root_src_directory.join(gpa, &.{
- file.sub_file_path,
- });
+
+ const resolved_path = std.fs.path.resolve(
+ gpa,
+ if (file.pkg.root_src_directory.path) |pkg_path|
+ &[_][]const u8{ pkg_path, file.sub_file_path }
+ else
+ &[_][]const u8{file.sub_file_path},
+ ) catch |err| {
+ try reportRetryableFileError(mod, file, "unable to resolve path: {s}", .{@errorName(err)});
+ return error.AnalysisFail;
+ };
errdefer gpa.free(resolved_path);
try man.addFilePostContents(resolved_path, source.bytes, source.stat);