lua-protobuf icon indicating copy to clipboard operation
lua-protobuf copied to clipboard

reserved keyword in enum definition

Open RevengeComing opened this issue 4 years ago • 4 comments

Hi there,

I recently faced a bug that if there's a reserved keyword in enum definition it will raise an error.

For example, I have this proto definition:

message Icon {
    enum Name {
        reserved 5, 96;
        ...
    }
}

At this line of the code it expects to have '=' but there's not and it will raise an error.

Unfortunately, I need a deep understanding of the code, If you give me some hint I can contribute and help to fix it.

RevengeComing avatar Nov 17 '20 12:11 RevengeComing

IMHO it's not allowed by protobuf syntax: https://developers.google.com/protocol-buffers/docs/reference/proto3-spec#enum_definition

so maybe you should change your schema file...

starwing avatar Nov 27 '20 11:11 starwing

@starwing Hi, I meet this problem too, and it seems this should be legal? https://developers.google.com/protocol-buffers/docs/proto3#reserved_values.

And it is worked under golang:

enum Foo {
  reserved 2, 15, 9 to 11, 40 to max;
  reserved "FOO", "BAR";
}

rainingmaster avatar Jul 26 '21 04:07 rainingmaster

Okay, It seems protobuf3 language reference out of updated. I will add this feature in time.

starwing avatar Jul 31 '21 02:07 starwing

landed on https://github.com/starwing/lua-protobuf/commit/a0ef7a33ac980f005e3e02e8fe5d99bb36dcdd5f

starwing avatar Jul 31 '21 03:07 starwing