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

protoc-gen-go: fix oneof name mangling regression #782

Merged
merged 1 commit into from Jan 9, 2019
Merged

Conversation

dsnet
Copy link
Member

@dsnet dsnet commented Jan 8, 2019

The generator currently uses an unintuitive and stateful algorithm
for name generation where it "fixes" name conflicts by appending "_"
to the end of the new name.

PR#657 refactored the generator code and noticed that the above
algorithm was not properly taking into account that a Get method is
generated for parent oneofs, fixing it in the same PR. While this is
more correct, this breaks users (see #780) since it means that the
generation of names can change.

This PR changes the name mangling logic to be as it was previously.
This does mean that some new proto files may be unbuildable,
but that is arguably better than breaking existing proto files.

Fixes #780

The generator currently uses an unintuitive and stateful algorithm
for name generation where it "fixes" name conflicts by appending "_"
to the end of the new name.

PR#657 refactored the generator code and noticed that the above
algorithm was not properly taking into account that a Get method is
generated for parent oneofs, fixing it in the same PR. While this is
more correct, this breaks users (see #780) since it means that the
generation of names can change.

This PR changes the name mangling logic to be as it was previously.
This does mean that some new proto files may be unbuildable,
but that is arguably better than breaking existing proto files.

Fixes #780
@dsnet dsnet requested a review from neild January 8, 2019 19:06
Copy link
Contributor

@neild neild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh.

@dsnet
Copy link
Member Author

dsnet commented Jan 8, 2019

Before submitting, I'll run this through code at Google to make sure nothing depends on the new mangling semantics.

@dsnet
Copy link
Member Author

dsnet commented Jan 9, 2019

No failures.

@dsnet dsnet merged commit 347cf4a into master Jan 9, 2019
@dsnet dsnet deleted the oneof-conflict branch January 9, 2019 07:22
@golang golang locked and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

protoc-gen-go: unexpected trailing underscore in oneof field name
2 participants