-
Notifications
You must be signed in to change notification settings - Fork 15
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
Make fields optional for non-primitive protobuf fields #92
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @noelmarkham , thanks for your contribution!
I would avoid adding new cases to ASTs, which make it difficult to make transformations (and will make it harder to migrate to the UAST later, you can see what UAST is here #61)
can you try representing the same thing using a TOption(TNamedType(name).embed)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks @noelmarkham !
I think you will need to have separate handling for proto3 vs proto2 syntax. In proto2 fields are optional by default but can be marked as required. In proto3 all fields are always optional. |
@eli-jordan Yep, we're planning to have different printers in the future for proto2 and proto3. Thanks for your comment! |
Is there a follow up bug explicitly for proto2 vs proto3 support for primitive fields? The appeal of proto2 is that you can tell whether a field has been explicitly set. For example It feels a bit odd that this support only extends to non-primitive fields. |
Added a new field, TOptionalNamedType for higherkindness/mu-scala#612 - Protobuf requiring optional fields for non-primitive types.
Would appreciate feedback on this; I feel this can't be everything I need to do for this to be complete.