Skip to content

Commit

Permalink
main: avoid sending an empty file system inputs message
Browse files Browse the repository at this point in the history
When all compiler inputs are invalid paths, there could be errors yet no
valid file system inputs.

Closes ziglang#20713
  • Loading branch information
jacobly0 authored and SammyJames committed Aug 7, 2024
1 parent aaa154d commit e9d663b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4207,13 +4207,17 @@ fn serve(
fn serveUpdateResults(s: *Server, comp: *Compilation) !void {
const gpa = comp.gpa;

var error_bundle = try comp.getAllErrorsAlloc();
defer error_bundle.deinit(gpa);

if (comp.file_system_inputs) |file_system_inputs| {
assert(file_system_inputs.items.len > 0);
try s.serveStringMessage(.file_system_inputs, file_system_inputs.items);
if (file_system_inputs.items.len == 0) {
assert(error_bundle.errorMessageCount() > 0);
} else {
try s.serveStringMessage(.file_system_inputs, file_system_inputs.items);
}
}

var error_bundle = try comp.getAllErrorsAlloc();
defer error_bundle.deinit(gpa);
if (error_bundle.errorMessageCount() > 0) {
try s.serveErrorBundle(error_bundle);
return;
Expand Down

0 comments on commit e9d663b

Please sign in to comment.