Return a descriptive error when a map field has a nil element.
I'm not sure if this matches C++, but it makes sense and otherwise
the output is not decodable by this same package. It also parallels
our rejection of nil elements of a repeated field.
diff --git a/proto/all_test.go b/proto/all_test.go
index 8784187..5a9b6a4 100644
--- a/proto/all_test.go
+++ b/proto/all_test.go
@@ -1925,6 +1925,18 @@
}
}
+func TestMapFieldWithNil(t *testing.T) {
+ m := &MessageWithMap{
+ MsgMapping: map[int64]*FloatingPoint{
+ 1: nil,
+ },
+ }
+ b, err := Marshal(m)
+ if err == nil {
+ t.Fatalf("Marshal of bad map should have failed, got these bytes: %v", b)
+ }
+}
+
// Benchmarks
func testMsg() *GoTest {