Thanks Feng.

It does look like the documentation is wrong then.  I checked, and the
"Reserved" section shows up when looking at the Language Guide for both
proto2 and proto3.

On Wed, May 25, 2016 at 8:01 PM, Feng Xiao <xiaof...@google.com> wrote:

>
>
> On Wed, May 25, 2016 at 5:49 PM, Marcos Juarez <mjua...@gmail.com> wrote:
>
>> I just realized, there's a typo in my example.  It should say:
>>
>>    reserved 4, 108, 109;
>>
>> Note there's no comma after the reserved keyword.
>>
>> Also, I checked, and the protoc compiler I'm using reports itself as:  
>> *libprotoc
>> 2.5.0*
>>
> The reserved keyword was added in v3.0.0-alpha-3:
> https://github.com/google/protobuf/releases/tag/v3.0.0-alpha-3
>
> You have to upgrade your protobuf version to use it.
>
>
>>
>>
>> On Wed, May 25, 2016 at 3:44 PM, Marcos Juarez <mjua...@gmail.com> wrote:
>>
>>> I ran into a situation today in which I needed to use the "reserved"
>>> keyword in a protobuf definition, so that in the future, nobody would use
>>> those fields.  I've attached a screenshot of what the docs say, from
>>> https://developers.google.com/protocol-buffers/docs/proto#reserved
>>>
>>> [image: Inline image 1]
>>>
>>> However, when I try to use that keyword in an actual message with field
>>> definitions, protoc always complains with the following error:
>>>
>>> *Expected "required", "optional", or "repeated".*
>>>
>>> My protobuf definition looks like this:
>>>
>>> message MyMessage {
>>>       // Some comments
>>>       reserved, 4, 108, 109;
>>>
>>>       // Some more comments
>>>       required string event_uuid            = 1     ;
>>>       required string date                  = 2     ;
>>>       required string timezone              = 3     ;
>>>
>>>       optional string field1                = 101   ;
>>>       optional string field2                = 110   ;
>>> }
>>>
>>> Am I reading that spec wrong, or is the reserved keyword broken?
>>>
>>> Marcos
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Protocol Buffers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to protobuf+unsubscr...@googlegroups.com.
>> To post to this group, send email to protobuf@googlegroups.com.
>> Visit this group at https://groups.google.com/group/protobuf.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to