Commit 224fbb23c4

Andrew Kelley <andrew@ziglang.org>
2021-04-24 08:51:27
stage2: better error reporting for LazySrcLoc.entire_file
instead of crashing the compilation, uses a plain error message
1 parent 27fa4bc
Changed files (1)
src/Compilation.zig
@@ -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);