From 9034c901849bd68266a6f0080304254beffe00d1 Mon Sep 17 00:00:00 2001 From: antlilja Date: Fri, 24 Dec 2021 23:29:31 +0100 Subject: [PATCH] Fix order of handling of optional error union type std.process.args().next(...) returns an optional error union type, the potential error has to be handled before the optional can be unwrapped. --- generator/main.zig | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/generator/main.zig b/generator/main.zig index a07ca55..ff16e11 100644 --- a/generator/main.zig +++ b/generator/main.zig @@ -11,14 +11,12 @@ pub fn main() !void { const allocator = arena.allocator(); var args = std.process.args(); - const prog_name = try args.next(allocator) orelse return error.ExecutableNameMissing; + const prog_name = (try args.next(allocator)) orelse return error.ExecutableNameMissing; var maybe_xml_path: ?[]const u8 = null; var maybe_out_path: ?[]const u8 = null; - while (args.next(allocator)) |err_or_arg| { - const arg = try err_or_arg; - + while (try args.next(allocator)) |arg| { if (std.mem.eql(u8, arg, "--help") or std.mem.eql(u8, arg, "-h")) { @setEvalBranchQuota(2000); try stderr.writer().print(