authorgravatar for jcmoyer32@gmail.comJ.C. Moyer <jcmoyer32@gmail.com> 2021-06-24 01:41:54-04:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-06-27 14:53:46+03:00
log15a030ef3d2d68992835568f2fb9d5deab18f39f
treed41539edd628a4caef049806bd49211e0bf4a6a0
parentf398ac3ee48b35754f51f0bfaff76b6a1e70da77

Include package root dir in stage2 error messages


2 files changed, 10 insertions(+), 6 deletions(-)

src/Compilation.zig+6-6
......@@ -403,10 +403,10 @@ pub const AllErrors = struct {
403403 const source = try module_note.src_loc.file_scope.getSource(module.gpa);
404404 const byte_offset = try module_note.src_loc.byteOffset(module.gpa);
405405 const loc = std.zig.findLineColumn(source, byte_offset);
406 const sub_file_path = module_note.src_loc.file_scope.sub_file_path;
406 const file_path = try module_note.src_loc.file_scope.fullPath(&arena.allocator);
407407 note.* = .{
408408 .src = .{
409 .src_path = try arena.allocator.dupe(u8, sub_file_path),
409 .src_path = file_path,
410410 .msg = try arena.allocator.dupe(u8, module_note.msg),
411411 .byte_offset = byte_offset,
412412 .line = @intCast(u32, loc.line),
......@@ -426,10 +426,10 @@ pub const AllErrors = struct {
426426 const source = try module_err_msg.src_loc.file_scope.getSource(module.gpa);
427427 const byte_offset = try module_err_msg.src_loc.byteOffset(module.gpa);
428428 const loc = std.zig.findLineColumn(source, byte_offset);
429 const sub_file_path = module_err_msg.src_loc.file_scope.sub_file_path;
429 const file_path = try module_err_msg.src_loc.file_scope.fullPath(&arena.allocator);
430430 try errors.append(.{
431431 .src = .{
432 .src_path = try arena.allocator.dupe(u8, sub_file_path),
432 .src_path = file_path,
433433 .msg = try arena.allocator.dupe(u8, module_err_msg.msg),
434434 .byte_offset = byte_offset,
435435 .line = @intCast(u32, loc.line),
......@@ -480,7 +480,7 @@ pub const AllErrors = struct {
480480
481481 note.* = .{
482482 .src = .{
483 .src_path = try arena.dupe(u8, file.sub_file_path),
483 .src_path = try file.fullPath(arena),
484484 .msg = try arena.dupe(u8, msg),
485485 .byte_offset = byte_offset,
486486 .line = @intCast(u32, loc.line),
......@@ -506,7 +506,7 @@ pub const AllErrors = struct {
506506
507507 try errors.append(.{
508508 .src = .{
509 .src_path = try arena.dupe(u8, file.sub_file_path),
509 .src_path = try file.fullPath(arena),
510510 .msg = try arena.dupe(u8, msg),
511511 .byte_offset = byte_offset,
512512 .line = @intCast(u32, loc.line),
src/Module.zig+4
......@@ -1111,6 +1111,10 @@ pub const Scope = struct {
11111111 return buf.toOwnedSliceSentinel(0);
11121112 }
11131113
1114 pub fn fullPath(file: File, ally: *Allocator) ![]u8 {
1115 return file.pkg.root_src_directory.join(ally, &[_][]const u8{file.sub_file_path});
1116 }
1117
11141118 pub fn dumpSrc(file: *File, src: LazySrcLoc) void {
11151119 const loc = std.zig.findLineColumn(file.source.bytes, src);
11161120 std.debug.print("{s}:{d}:{d}\n", .{ file.sub_file_path, loc.line + 1, loc.column + 1 });