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

[Proto3] Error compiling reserved values in enum #4010

Closed
lesliechang opened this issue Dec 7, 2017 · 7 comments
Closed

[Proto3] Error compiling reserved values in enum #4010

lesliechang opened this issue Dec 7, 2017 · 7 comments

Comments

@lesliechang
Copy link

According to this documentation for proto3 (https://developers.google.com/protocol-buffers/docs/proto3#enum_reserved), you can add reserved values using the reserved statement, but this no longer compiles.

enum Foo {
  reserved 2, 15, 9 to 11, 40 to max;
  reserved "FOO", "BAR";
}
@xfxyjwf
Copy link
Contributor

xfxyjwf commented Dec 7, 2017

What's the error message?

@lesliechang
Copy link
Author

Missing numeric value for enum constant.

@liujisi
Copy link
Contributor

liujisi commented Dec 7, 2017

Which version were you using? This I believe was first introduced in 3.5.0.

@xfxyjwf xfxyjwf closed this as completed Dec 11, 2017
@yingzong
Copy link

yingzong commented Mar 19, 2018

Confirmed that on 3.5.0, reserved works, however it says "The first enum value must be zero in proto3." So it seems 0 cannot be reserved.

@ElectricRCAircraftGuy
Copy link

ElectricRCAircraftGuy commented Nov 19, 2019

Why is is that you are saying protobuf version must be >= 3.5.0 when the protobuf documentation shows reserved as a functional keyword for both proto2 and proto3?--as though reserved should have been working long before 3.5.0.

@acozzette
Copy link
Member

Sorry for the confusion around this but usually when we talk about proto2 and proto3 we don't mean the version number (like 3.5.0) but instead we are talking about whether you have syntax = "proto2" or syntax = "proto3" at the top of your .proto file. We are actively maintaining both proto2 and proto3, so we have introduced some new proto2 features in 3.x releases.

@ElectricRCAircraftGuy
Copy link

ElectricRCAircraftGuy commented Nov 20, 2019

I see. That makes sense. Thanks for clarifying this. It would be worth the effort to document it somewhere clearly, perhaps on the readme page or at the tops of the proto2 and proto3 pages I linked to above.

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

6 participants