From 3e38a4fc844e572ee0a8b5cb61558763de0f2157 Mon Sep 17 00:00:00 2001 From: Manlio Perillo Date: Sat, 20 May 2023 07:21:11 +0200 Subject: [PATCH] build: in `ZiglingStep.check_output` panic in case of OOM This is necessary since, when trimLines returns `std.mem.Allocator.Error`, no error message will be displayed to the user. An alternative is to use `std.Build.Step.fail`, but using @panic("OOM") is simpler and consistent with existing code. --- build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 1823919..9b8a1ee 100644 --- a/build.zig +++ b/build.zig @@ -304,7 +304,7 @@ const ZiglingStep = struct { // Validate the output. // NOTE: exercise.output can never contain a CR character. // See https://ziglang.org/documentation/master/#Source-Encoding. - const output = try trimLines(b.allocator, raw_output); + const output = trimLines(b.allocator, raw_output) catch @panic("OOM"); const exercise_output = self.exercise.output; if (!std.mem.eql(u8, output, self.exercise.output)) { return self.step.fail(