Skip to content

Support negative numbers on reserved keyword for Enums #1214

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fenos
Copy link

@fenos fenos commented May 3, 2019

This PR Fixes bloomrpc/bloomrpc#35

As well as enabling negative numbers on reserved keywords for Enums types

example:

enum Values {
    reserved -1;
    INVALID = 0;
    OK = 1;
    OK_BUT_WARNINGS = 2;
  }

Before this PR there was a parsing issue when using negative numbers on reserved keywords

@alexander-fenster
Copy link
Contributor

The proto3 spec shows that the reserved field cannot be negative:

reserved = "reserved" ( ranges | fieldNames ) ";"
ranges = range { "," range }
range =  intLit [ "to" ( intLit | "max" ) ]
fieldNames = fieldName { "," fieldName }

intLit     = decimalLit | octalLit | hexLit
decimalLit = ( "1" … "9" ) { decimalDigit }
octalLit   = "0" { octalDigit }
hexLit     = "0" ( "x" | "X" ) hexDigit { hexDigit } 

protoc supports that, so it might be just an error in the spec. We'll clarify it with protobuf team and will merge if they say it's OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Illegal id -1 for reserved -1;
2 participants