Repository navigation
v1.8.2
This release contains numerous improvements to the protoparse package, to more closely match protoc in terms of proto source files that are acceptable.
"github.com/jhump/protoreflect/desc/protoparse"
Changes/fixes:
- Extensions in a
syntax = "proto3"source file were not allowed to have anoptionalkeyword. However, as of the addition of "proto3 optional" support, this is now allowed byprotoc. Soprotoparsenow accepts such declarations, to matchprotocfunctionality.- Extensions that have an explicit
optionalkeyword are marked in the descriptor with theproto3_optionaloption. But, unlike normal fields with theproto3_optionaloption set, they are not (and, in fact, cannot be) included in implicit single-field oneofs.
- Extensions that have an explicit
- The official compiler,
protoc, rejects proto source files for the following reasons. However theprotoparsewould accept such invalid source files. This has been remedied andprotoparsealso now rejects such programs:- An enum cannot contain a value named
optionorreserved. This is not an explicit check but is instead a limitation of how theprotocparser works: it assumes these keywords indicate options or reserved ranges, not the start of values with these names. - A message cannot begin a field declaration with the keyword
reserved, for example in a proto3 file where a type (message or enum) namedreservedis also defined. Similar to above, theprotocparser will never recognize such a statement as a field, but protoparse would. - A oneof cannot contain a field whose name matches a label keyword (
optional,repeated, orrequired). Unlike the above two, this is not related to limits of the parser but is instead an explicit check to prevent common errors: since oneof blocks do not contain labels, a field thusly named is more likely to be a typo even if otherwise syntactically correct. - An enum can only allow aliases (via
option allow_alias = true;) if it actually contains values that are aliases. Put another way: if there are no aliases, this option must not be set. - A message cannot use message-set wire format (via
option message_set_wire_format = true;) if it has any normal fields. Message sets must have only extension fields. Similarly, a message cannot use message-set wire format if it has no extension ranges. - An extension for a message that uses message-set wire format must be a message type; scalar extensions are not allowed for messages that use message-set wire format.
- An enum cannot contain a value named