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 #20713
  • Loading branch information
jacobly0 authored and andrewrk committed Jul 25, 2024
1 parent f4f5b2b commit 18685e9
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 18685e9

Please sign in to comment.