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 committed Jul 24, 2024
1 parent 4de8bba commit 02e662d
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 02e662d

Please sign in to comment.