We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When unmarshaling an empty message embedded in another message, vtprotobuf is allocating the message, but proto.Unmarshal is using a typed nil.
Steps to reproduce:
syntax = "proto3"; package repro; message TopLevel { message Empty {} Empty embedded = 1; }
func TestEmbeddedEmpty(t *testing.T) { m := &pb.TopLevel{Embedded: &pb.TopLevel_Empty{}} // Marshal it with protobuf. protobuf, err := proto.Marshal(m) if err != nil { t.Fatal(err) } // Unmarshal it with protobuf. pbm := &pb.TopLevel{} if err := proto.Unmarshal(protobuf, m); err != nil { t.Fatal(err) } // Unmarshal it with vtprotobuf. vtm := &pb.TopLevel{} if err := vtm.UnmarshalVT(protobuf); err != nil { t.Fatal(err) } fmt.Printf("%#v\n\n", pbm) fmt.Printf("%#v\n", vtm) require.True(t, pbm.EqualVT(vtm), "EqualVT") require.True(t, proto.Equal(pbm, vtm), "proto.Equal") }
Output:
&proto.TopLevel{state:impl.MessageState{NoUnkeyedLiterals:pragma.NoUnkeyedLiterals{}, DoNotCompare:pragma.DoNotCompare{}, DoNotCopy:pragma.DoNotCopy{}, atomicMessageInfo:(*impl.MessageInfo)(nil)}, sizeCache:0, unknownFields:[]uint8(nil), Embedded:(*proto.TopLevel_Empty)(nil)} &proto.TopLevel{state:impl.MessageState{NoUnkeyedLiterals:pragma.NoUnkeyedLiterals{}, DoNotCompare:pragma.DoNotCompare{}, DoNotCopy:pragma.DoNotCopy{}, atomicMessageInfo:(*impl.MessageInfo)(nil)}, sizeCache:0, unknownFields:[]uint8(nil), Embedded:(*proto.TopLevel_Empty)(0xc00011fbc0)} --- FAIL: TestEmbeddedEmpty (0.00s) main_test.go:37: Error Trace: main_test.go:37 Error: Should be true Test: TestEmbeddedEmpty Messages: EqualVT FAIL exit status 1
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When unmarshaling an empty message embedded in another message, vtprotobuf is allocating the message, but proto.Unmarshal is using a typed nil.
Steps to reproduce:
Output:
The text was updated successfully, but these errors were encountered: