jvolkman / intellij-protobuf-editor

Protocol Buffers for IntelliJ-based IDEs
Apache License 2.0
122 stars 15 forks source link

False positive when linting enum value named `option` #50

Closed sgtsquiggs closed 3 years ago

sgtsquiggs commented 3 years ago

Example:

enum EnumWithOptionValue {
  zero = 0;
  first = 1;
  second = 2;
  option = 3;
}

Errors with:

illegal name '=' (/path/to/file.proto, line XXX)

It seems to be assuming that option is something like option allow_alias = true; yet the above protobuf is perfectly valid.

jvolkman commented 3 years ago

What version of protoc? That is not valid with the current version of protoc from what I can tell.

$ cat tst.proto                                             
syntax="proto2";
enum EnumWithOptionValue {
  zero = 0;
  first = 1;
  second = 2;
  option = 3;
}

$ protoc --version                      
libprotoc 3.14.0

$ protoc tst.proto -o out.pb
tst.proto:6:10: Expected identifier.

You can see in the official parser that if lines within an enum block start with option or reserved, different paths are followed. No attempt is made to parse these lines as enum constants.

sgtsquiggs commented 3 years ago

Interesting - I've been using buf to compile protobuf for the past few months. Seems it isn't 1:1 yet.