From b6f99ee15a96e96581d3ff092c499de4ff611c05 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Fri, 12 Nov 2021 16:43:04 +0100 Subject: [PATCH] Remove redundant error returns for unions --- lib/xdrgen/generators/go.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/xdrgen/generators/go.rb b/lib/xdrgen/generators/go.rb index d8f4368c7..6b5f7e13c 100644 --- a/lib/xdrgen/generators/go.rb +++ b/lib/xdrgen/generators/go.rb @@ -570,7 +570,9 @@ def render_union_decode_from_interface(out, union) out2.puts " return n, nil" out2.string end - out.puts " return n, fmt.Errorf(\"#{name(union.discriminant)} (#{reference union.discriminant.type}) switch value '%d' is not valid for union #{name}\", u.#{name(union.discriminant)})" + unless union.default_arm.present? + out.puts " return n, fmt.Errorf(\"#{name(union.discriminant)} (#{reference union.discriminant.type}) switch value '%d' is not valid for union #{name}\", u.#{name(union.discriminant)})" + end out.puts "}" out.break end