stage2: better error reporting for LazySrcLoc.entire_file

instead of crashing the compilation, uses a plain error message
This commit is contained in:
Andrew Kelley 2021-04-23 23:51:27 -07:00
parent 27fa4bc2be
commit 224fbb23c4

View File

@ -405,6 +405,14 @@ pub const AllErrors = struct {
},
};
}
if (module_err_msg.src_loc.lazy == .entire_file) {
try errors.append(.{
.plain = .{
.msg = try arena.allocator.dupe(u8, module_err_msg.msg),
},
});
return;
}
const source = try module_err_msg.src_loc.file_scope.getSource(module.gpa);
const byte_offset = try module_err_msg.src_loc.byteOffset();
const loc = std.zig.findLineColumn(source, byte_offset);