vtprotobuf
vtprotobuf copied to clipboard
equal: Fix handling of nil values
The current equal implementation generates code that recognizes a nil message as being equal to an empty message of the same type. However, this is not how proto.Equal works, where a nil message is only equal to another nil message of the same type.
A complication arises from the fact that nil and empty message values need to be treated as equal in certain contexts - slice elements, map values, oneofs. This is the same principle as the one described in https://github.com/planetscale/vtprotobuf/issues/52, only applied to messages instead of byte slices.
This PR solves this by propagating the nullable (i.e., presence) information to the code generator for comparing message values, and substituting nil values for empty ones for non-nullable values.