mransan/ocaml-protoc

Enum names clashing with internal OCaml types

Opened this issue · 0 comments

With the following in test.proto:

syntax = "proto3";

message A { bool a = 0; }

message B {
  enum C { NONE = 0; }
}

message D { A a = 0; }

Running

ocaml-protoc -ocaml_all_types_ppx "deriving show" -ml_out ./ test.proto

creates some files. The test_types.ml has the following content:

[@@@ocaml.warning "-27-30-39"]


type a = {
  a : bool;
}
[@@deriving show]

type b_c =
  | None 
[@@deriving show]

type d = {
  a : a option;
}
[@@deriving show]

let rec default_a 
  ?a:((a:bool) = false)
  () : a  = {
  a;
}

let rec default_b_c () = (None:b_c)

let rec default_d 
  ?a:((a:a option) = None)
  () : d  = {
  a;
}

which fails to build:

File "test_types.ml", line 14, characters 6-14:
14 |   a : a option;
           ^^^^^^^^
Error: This variant pattern is expected to have type b_c
       The constructor Some does not belong to type b_c

(building with dune and using ocaml-protoc pinned to master)