From 51232cb45ecdc956674d4998b2dfaa6b35b3ee3a Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Sat, 28 May 2022 15:50:07 -0700 Subject: [PATCH] get more defensive from compiler bugs --- src/xml_shaper.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xml_shaper.zig b/src/xml_shaper.zig index 034ed54..37ebb38 100644 --- a/src/xml_shaper.zig +++ b/src/xml_shaper.zig @@ -145,7 +145,8 @@ fn parseInternal(comptime T: type, element: *xml.Element, options: ParseOptions) if (element.children.items.len == 0) { // This is almost certainly incomplete. Empty strings? xsi:nil? return null; - } else { + } + if (element.children.items.len > 0) { // return try parseInternal(optional_info.child, element.elements().next().?, options); return try parseInternal(optional_info.child, element, options); } @@ -180,9 +181,8 @@ fn parseInternal(comptime T: type, element: *xml.Element, options: ParseOptions) // } // } return error.NoUnionMembersMatched; - } else { - @compileError("Unable to parse into untagged union '" ++ @typeName(T) ++ "'"); } + @compileError("Unable to parse into untagged union '" ++ @typeName(T) ++ "'"); }, .Struct => |struct_info| { var r: T = undefined;