Skip to content
New issue

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

Please add optional back to the AST #229

Open
xeinherjar opened this issue Feb 28, 2023 · 1 comment
Open

Please add optional back to the AST #229

xeinherjar opened this issue Feb 28, 2023 · 1 comment

Comments

@xeinherjar
Copy link

It looks like Optional was removed in this PR: https://github.com/awakesecurity/proto3-suite/pull/165/files

The reason given was that it wasn't supported in proto3, but it is in fact part of the spec, see: https://protobuf.dev/programming-guides/proto3/#specifying-field-rules

Specifying Field Rules 
Message fields can be one of the following:

singular: a well-formed message can have zero or one of this field (but not more than one). When using proto3 syntax, this is the default field rule when no other field rules are specified for a given field. You cannot determine whether it was parsed from the wire. It will be serialized to the wire unless it is the default value. For more on this subject, see [Field Presence](https://protobuf.dev/programming-guides/field_presence).
optional: the same as singular, except that you can check to see if the value was explicitly set. An optional field is in one of two possible states:
the field is set, and contains a value that was explicitly set or parsed from the wire. It will be serialized to the wire.
the field is unset, and will return the default value. It will not be serialized to the wire.
repeated: this field type can be repeated zero or more times in a well-formed message. The order of the repeated values will be preserved.
map: this is a paired key/value field type. See [Maps](https://protobuf.dev/programming-guides/encoding#maps) for more on this field type.

It was erroneously left out of early documentation per: protocolbuffers/protobuf#10463

Can that PR be reverted?

@gbaz
Copy link
Collaborator

gbaz commented Mar 1, 2023

I don't think putting back optional on its own suffices. The spec gives a new behavior to it, which we'd have to take into account in the code as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants