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: reserved names are not validated #6335

Open
dsnet opened this issue Jul 3, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@dsnet
Copy link
Contributor

commented Jul 3, 2019

Consider the following proto file:

message M {
    optional string foo = 1; 
    reserved "foo bar";
}

Here, "foo bar" is clearly an invalid identifier. The intention of the user is to specify two different identifiers "foo" and "bar" as reserved. Since the reserved name logic looks for exact matches, it does not warn the user that a reserved name is being used.

I expect protoc to fail if any reserved identifier is invalid.

@dsnet

This comment has been minimized.

Copy link
Contributor Author

commented Jul 3, 2019

Related problem:

message M {
    optional string foo = 1; 
    reserved "foo" "bar";
}

Again, the intention is to specify "foo" and "bar" as two separate identifiers. However, since protoc seems to be applying a textproto-like grammar, "foo" "bar" is treated as a single concatenated string "foobar".

The distinction between:

  • reserved "foo bar";
  • reserved "foo" "bar";
  • reserved "foo", "bar";

is too subtle and error prone.

@dsnet

This comment has been minimized.

Copy link
Contributor Author

commented Jul 3, 2019

Also, the current behavior goes against the grammar specification, which says that the token should be a fieldName which is equivalent to the ident token.

Related: https://developers.google.com/protocol-buffers/docs/reference/proto3-spec#reserved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.