Skip to content

Reserved fields not allowed in enums. #256

Description

@benoit-sb

Hi and thanks for the project! I have found a small issue which is not blocking but yet interesting to point out.

Issue

ocaml-protoc cannot compile an enum that contains the reserved keyword.

Steps to reproduce

Write a myenum.proto file with the following content

// myenum.proto
syntax = "proto3";

enum MyEnum {
  foo = 0;
  reserved 1;
}

Compile it with ocaml-protoc

$ ocaml-protoc ./myenum.proto --ml_out .
./myenum.proto:5:10: Parsing error at `foo = 0 ; reserved <<< HERE'.
zsh: exit 1

However it works as expected with the official protoc compiler

$ protoc --python_out=. ./myenum.proto
zsh: exit 0

Workaround

Replace the reserved keyword by a field which explicitly prevents usage.

enum MyEnum {
  foo = 0;
  OBSOLETE_bar = 1 [deprecated = true];
}

Versions

ocaml-protoc: 3.1.1
ocaml: 4.14.2

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions