-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
C style enum name scoping rules should be documented. #6912
Comments
This restriction is completely bogus and imho it should be removed. protoc for:
in C++ generator will happily prefix all enum labels with enum names automatically in .pb.h:
so if AnotherEnum was allowed to be generated, there would be no name collision. Python generator may behave differently. Own this design mistake guys - either remove this restriction and update generators to generate enum labels in unique fashion or update generators to actually adhere to it - do no append enum type name to generated enum value labels (like in C++ one). What we have now is the worst of two worlds:
Which results with generated labels like: About inevitable "do not append enum type name to enum label".
Using fake message container for namespace reasons is a workaround. How about making a fix instead for a change? |
Just wondering if there is any update on this request. From the C-side, being forced to use unique enum labels in the same module is quite cumbersome. It would be good to know if there is any planned resolution on this. |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment. This issue is labeled |
This seems to still be relevant |
Thanks for keeping this issue open, @Levi-Lesches . |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment. This issue is labeled |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it. This issue was closed and archived because there has been no new activity in the 14 days since the |
What language does this apply to? All
Describe the problem you are trying to solve.
There is some confusion about enum key naming rules around sibling enums not being allowed values with the same name. Some google searching helps (and the protoc error message iirc), but it's not very clear:
#5425
https://stackoverflow.com/questions/27030332/solutions-to-resolve-enum-field-naming-restriction-in-google-protobuf-due-to-c
protobuf-net/protobuf-net#60
Describe the solution you'd like
The language guide (https://developers.google.com/protocol-buffers/docs/proto3#enum) should explain that defining two enums in the same package with values that have the same name (e.g.
UNKNOWN
) is invalid, and whether the same is true or not when one or both of the enums are nested inside a message.It would also be nice if the code examples for enum were valid with respect to this rule, and followed the style guide with
XXX_UNSPECIFIED
rather thanUNKNOWN
. One of the current code examples is:The text was updated successfully, but these errors were encountered: