yoheimuta / go-protoparser

Yet another Go package which parses a Protocol Buffer file (proto2+proto3)
MIT License
166 stars 20 forks source link

UnorderedInterpret: handle EmptyStatement in MessageBody #72

Closed jtxyz closed 2 years ago

jtxyz commented 2 years ago

An additional trailing semicolon in the body of a message currently causes UnorderedInterpret to fail.

For example, changing the example proto file from the README

https://github.com/yoheimuta/go-protoparser/blob/a1aa0a07fe86a183dd06da85e9c5ef6f9a11faa1/README.md?plain=1#L36-L44

to add an additional semicolon somewhere in outer (e.g. option (my_option).a = true;;) causes the following error to be returned:

invalid MessageBody type &{<nil>} of &{<nil>}

This PR causes these empty statements to be included on the returned MessageBody instead.


While debugging this issue, I also noticed the error message was repeating the same format argument. In the second commit I fixed the error messages so they contain the name of the invalid type and then a representation of the value.

invalid MessageBody type *parser.SomeUnexpectedStatement of &{<nil>}
yoheimuta commented 2 years ago

I've cut a new release.