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

Naming conflict when oneof begins with Set, fails to compile #686

Open
sppalkia opened this issue Oct 23, 2023 · 1 comment
Open

Naming conflict when oneof begins with Set, fails to compile #686

sppalkia opened this issue Oct 23, 2023 · 1 comment

Comments

@sppalkia
Copy link

I have a Protobuf that looks something like this:

message Foo {
  oneof command {
    Bar bar = 1;
    SetBar bar = 2;
  }
}

message Bar {}
message SetBar {}

When I try to compile the Proto, I get an error along the lines of:

71  |     pub fn set_bar(&mut self, v: Bar) {
    |     ---------------------------------------------------------- other definition for `set_bar`
...
101 |     pub fn set_bar(&self) -> &SetBar {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definitions for `set_bar`

This is happening even if I set the generate_getter and generator_accessor to false. Is there any good workaround for this? Maybe it be possible to add an option for adding a prefix to getters, e.g., get_, to disambiguate such cases?

Thanks!

@kristopherbullinger
Copy link

i believe it is an error for you to use repeated field names in the oneof definition. when i try to reproduce this, i receive a build error:

codegen failed: parse and typecheck
  Caused by:
      0: using pure parser
      1: error in `protos/oneof.proto`: Non-unique field name: `bar`
      2: Non-unique field name: `bar`

Furthermore, when i use buf lint on this proto file, it says:

protos/oneof.proto:6:12:symbol "Foo.bar" already defined at oneof.proto:5:9

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